openhab / openhab-linuxpkg

Repo for Linux packages
Eclipse Public License 2.0
18 stars 33 forks source link

Better handling of openHAB startup problems in systemd #70

Closed ThomDietrich closed 6 years ago

ThomDietrich commented 7 years ago

Hey all, Hey @BClark09,

we are seeing problems similar to this quite often.

To the extend of your knowledge, can you think of any easy or practical way to have systemctl status actually report startup failures? It might be worth it to look into this topic. Best! Thomas

Also see: https://github.com/openhab/openhabian/issues/50#issuecomment-280868594

BClark09 commented 7 years ago

The output of systemctl status openhab2 --full and sudo journalctl -u openhab -b both give as much information as start.sh distribution provides. If start.sh continues successfully, then the service doesn't care what /usr/share/openhab2/runtime/karaf.

I don't know why start.sh exists, but if it's just to set the working directory for manual setups, we do this in the service script already, so should run the Karaf file directly. We should also remove the restart on failure flag (as the last error message will always be about too many restart attempts) and use a service file such as:

openhab2.service

[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]
Environment=OPENHAB_HOME=/usr/share/openhab2
Environment=OPENHAB_CONF=/etc/openhab2
Environment=OPENHAB_RUNTIME=/usr/share/openhab2/runtime
Environment=OPENHAB_USERDATA=/var/lib/openhab2
Environment=OPENHAB_LOGDIR=/var/log/openhab2
Environment=OPENHAB_STARTMODE=daemon
EnvironmentFile=-/etc/default/openhab2
User=openhab
Group=openhab
WorkingDirectory=/usr/share/openhab2
ExecStart=/usr/share/openhab2/runtime/bin/karaf $OPENHAB_STARTMODE
ExecStop=/usr/share/openhab2/runtime/bin/stop
TimeoutStopSec=120

[Install]
WantedBy=multi-user.target

/etc/default/openhab2 additions

#OPENHAB_STARTMODE=debug

wdyt?

ThomDietrich commented 7 years ago

Sounds and looks good! I will not be able to test now, will do that tomorrow! I'll also look into sd_notify.