[SOLVED] Openhab cannot start after upgrade (Ports not opened)

Hello
I had a working installation of OH2, until some apt-get update.
Tried to remove everything, and freshly install, to no avail.
Current situation is:

  • I start the OH2 service
  • Then I systemctl status openhab2
    And get
   Loaded: loaded (/etc/init.d/openhab2)
   Active: active (running) since Thu 2017-07-13 12:55:57 IDT; 9min ago
  Process: 2981 ExecStop=/etc/init.d/openhab2 stop (code=exited, status=0/SUCCESS)
  Process: 5369 ExecStart=/etc/init.d/openhab2 start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/openhab2.service
           ├─5466 /bin/bash /usr/share/openhab2/runtime/bin/karaf server
           └─5569 /usr/lib/jvm/jre-8-oracle-x64/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.logdir=/var/log/openhab2 -Dfelix.cm.dir=/var/lib/openh...

Jul 13 12:55:57 storage openhab2[5369]: Starting openHAB2 server: openhab2.
Jul 13 12:55:57 storage systemd[1]: Started LSB: openHAB2 server.

But ports 8080 and 8101 are not listening (saw using netstat -a | grep 8080 and alike)

All files in /usr/share/openhab2 are owned by openhab:openhab

As recommended, I issues journalctl -u openhab2 -b, but not sure it’s interesing:

-- Logs begin at Thu 2017-07-13 12:51:01 IDT, end at Thu 2017-07-13 14:47:36 IDT. --
Jul 13 12:51:15 storage systemd[1]: Starting LSB: openHAB2 server...
Jul 13 12:51:43 storage openhab2[676]: Starting openHAB2 server: openhab2.
Jul 13 12:51:43 storage systemd[1]: Started LSB: openHAB2 server.
Jul 13 12:53:12 storage systemd[1]: Stopping LSB: openHAB2 server...
Jul 13 12:53:13 storage openhab2[2981]: Stopping openHAB2 server: openhab2stop: Ignoring predefined value for KARAF_HOME
Jul 13 12:53:15 storage openhab2[2981]: Waiting for openHAB to stopWaiting for openHAB to stop..
Jul 13 12:53:15 storage systemd[1]: Stopped LSB: openHAB2 server.
Jul 13 12:55:56 storage systemd[1]: Starting LSB: openHAB2 server...
Jul 13 12:55:57 storage openhab2[5369]: Starting openHAB2 server: openhab2.
Jul 13 12:55:57 storage systemd[1]: Started LSB: openHAB2 server.
Jul 13 13:14:51 storage systemd[1]: Stopping LSB: openHAB2 server...
Jul 13 13:14:51 storage openhab2[19403]: Stopping openHAB2 server: openhab2stop: Ignoring predefined value for KARAF_HOME
Jul 13 13:15:53 storage openhab2[19403]: Waiting for openHAB to stopWaiting for openHAB to stop............................................................killing the process with pid 6659
Jul 13 13:15:53 storage openhab2[19403]: .
Jul 13 13:15:53 storage systemd[1]: Stopped LSB: openHAB2 server.
Jul 13 13:16:39 storage systemd[1]: Starting LSB: openHAB2 server...
Jul 13 13:16:40 storage openhab2[20973]: Starting openHAB2 server: openhab2.
Jul 13 13:16:40 storage systemd[1]: Started LSB: openHAB2 server.
Jul 13 13:23:16 storage systemd[1]: Stopping LSB: openHAB2 server...
Jul 13 13:23:17 storage openhab2[25700]: Stopping openHAB2 server: openhab2stop: Ignoring predefined value for KARAF_HOME
Jul 13 13:23:19 storage openhab2[25700]: Waiting for openHAB to stop.Waiting for openHAB to stop.
Jul 13 13:23:19 storage systemd[1]: Stopped LSB: openHAB2 server.
Jul 13 14:25:34 storage systemd[1]: Starting LSB: openHAB2 server...
Jul 13 14:25:35 storage openhab2[5356]: Starting openHAB2 server: openhab2.
Jul 13 14:25:35 storage systemd[1]: Started LSB: openHAB2 server.
Jul 13 14:31:38 storage systemd[1]: Stopping LSB: openHAB2 server...
Jul 13 14:31:38 storage openhab2[9574]: Stopping openHAB2 server: openhab2stop: Ignoring predefined value for KARAF_HOME
Jul 13 14:31:40 storage openhab2[9574]: Waiting for openHAB to stop.Waiting for openHAB to stop.
Jul 13 14:31:40 storage systemd[1]: Starting LSB: openHAB2 server...
Jul 13 14:31:41 storage openhab2[9812]: Starting openHAB2 server: openhab2.
Jul 13 14:31:41 storage systemd[1]: Started LSB: openHAB2 server.
root@storage:/usr/share/openhab2/runtime/bin# 

What am I missing ? Thanks in advance!

Hi @dorish, thanks for posting here.

Systemd seems to have gone through without any problems. Is there any output in /var/log/openhab2?

Thanks.
There’s only an empty file called /var/log/openhab2/Readme.txt
Nothing else in the directory.

Right, I think I see something unusual though. You mentioned that you used apt-get to update?

Your service file is pointing to start openHAB using /etc/init.d/openhab2 but there’s a predefined service file that does a much better job at running openHAB using systemd. Is there any reason why this is different to default (/usr/lib/systemd/system/openhab2.service)?

If you want to use openHAB’s defaults, We can try resetting systemd’s expectations, is the user:group responsible for openHAB openhab:openhab or have you changed this too? From this information, I should be able to give you a few commands to help diagnose the problem.

If it’s all okay to use defaults, then try:

sudo systemctl disable openhab2
sudo systemctl enable openhab2.service
sudo systemctl start openhab2.service

Hi Benji, and thanks for following (let alone so promptly!)
I don’t mind purging OH2 completely, and reinstalling if it makes things easy.
I tried to do in in the past by apt-get remove openhab2, then find any file mentioned openhab2 and rename to xxx-old
Now I don’t have any file called /usr/lib/systemd/system/openhab2.service (Only the old version)

I am using Debian 8.1
I use openhab:openhab for the user:group.

I did what you suggest in the last post:

root@storage:/home/dorish# systemctl disable openhab2
Synchronizing state for openhab2.service with sysvinit using update-rc.d...
Executing /usr/sbin/update-rc.d openhab2 defaults
Executing /usr/sbin/update-rc.d openhab2 disable
insserv: warning: current start runlevel(s) (empty) of script `openhab2' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `openhab2' overrides LSB defaults (0 1 6).
root@storage:/home/dorish# systemctl enable openhab2.service
Synchronizing state for openhab2.service with sysvinit using update-rc.d...
Executing /usr/sbin/update-rc.d openhab2 defaults
insserv: warning: current start runlevel(s) (empty) of script `openhab2' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `openhab2' overrides LSB defaults (0 1 6).
Executing /usr/sbin/update-rc.d openhab2 enable
root@storage:/home/dorish# systemctl start openhab2.service
root@storage:/home/dorish# 
root@storage:/home/dorish# 
root@storage:/home/dorish# systemctl status openhab2.service
â—Ź openhab2.service - LSB: openHAB2 server                                                                                                                                                       
   Loaded: loaded (/etc/init.d/openhab2)                                                                                                                                                        
   Active: active (exited) since Thu 2017-07-13 14:31:41 IDT; 8h ago                                                                                                                            
                                                                                                                                                                                                
Jul 13 14:31:41 storage openhab2[9812]: Starting openHAB2 server: openhab2.                                                                                                                     
Jul 13 14:31:41 storage systemd[1]: Started LSB: openHAB2 server.                                                                                                                               
Jul 13 22:49:02 storage systemd[1]: Started LSB: openHAB2 server.                                                                                                                               
root@storage:/home/dorish#                                                                                                                                                                      
root@storage:/home/dorish# ssh -p 8101 openhab@localhost                                                                                                                                        
ssh: connect to host localhost port 8101: Connection refused                                                                                                                                    
root@storage:/home/dorish# netstat -a | grep 8080
root@storage:/home/dorish#                                                                                                                                                                                                                                                     

Dorish

Hi @dorish, not a problem. To give you an insight into whats happening, the service deamon is trying to pick /etc/init.d/openhab because openhab2 does not exist. The file has not been reapplied because it’s trying to keep your choice (renaming it).

I would suggest recreating /usr/lib/systemd/system/openhab2.service by renaming the old file back to normal, or by creating a new one with the following contents (how they were at openHAB 2.1):

[Unit]
Description=openHAB 2 - empowering the smart home
Documentation=http://docs.openhab.org
Documentation=https://community.openhab.org
Wants=network-online.target
After=network-online.target

[Service]
EnvironmentFile=/etc/default/openhab2
User=openhab
Group=openhab
WorkingDirectory=/usr/share/openhab2
#PermissionsStartOnly=true
#ExecStartPre=/usr/share/openhab/bin/setpermissions.sh
ExecStart=/usr/share/openhab2/start.sh server
ExecStop=/usr/share/openhab2/runtime/bin/stop
# Shutdown delay in seconds, before process is tried to be killed with KILL (if configured)
TimeoutStopSec=120
Restart=on-failure

[Install]
WantedBy=multi-user.target

Then, try the three commands again, but with an extra one too:

sudo systemctl disable openhab2
sudo systemctl daemon-reload
sudo systemctl enable openhab2.service
sudo systemctl start openhab2.service

If this does not work, I would strongly suggest backing up /var/lib/openhab2 and /etc/openhab2 first and then sudo apt-get purge openhab2 which will delete everything. When you’re running with a new system, make sure you replace the entirety of /etc/openhab with what you had, and then the place back everything from /var/lib/openhab2 except:

/var/lib/openhab2/cache
/var/lib/openhab2/tmp
/var/lib/openhab2/etc
/var/lib/openhab2/.karaf
/var/lib/openhab2/.oracle*

After doing the above, then start openHAB with:

sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable openhab2.service
sudo /bin/systemctl start openhab2.service

Good luck!

Ok. Pasted your file’s content, did the 3 magic lines, now my house can think again :smiley:
I swear I’m not drunk, yet had to apt-get purge twice (!)
Thanks for the responsiveness.
Dorish

1 Like

did you use sudo? :slight_smile:

1 Like

Not a problem! Very glad you have it sorted!