50ButtonsEach / fliclib-linux-hci

Flic SDK for Linux
305 stars 55 forks source link

flicd exits when started with -d from service #86

Closed aboulfad closed 5 years ago

aboulfad commented 5 years ago

Hello, when starting flicd as a service and using -d option, the flicd process exits and never starts successfully. Running the same command as in the service from a login prompt works, and flicd runs in background.

System Info: Linux rpi3b+ 4.14.98-v7+ armv7l GNU/Linux

Here are the various extra-enabled logs, for unknown reason flicd (main process) runs and then immediately receives a SIGTERM from somewhere ! When using a service that does NOT use the -d option, flicd runs OK. I'd really appreciate some pointers to continue debugging this.

flicd.service ``` [Unit] Description=flicd Service [Service] Type=simple ExecStart=/usr/local/bin/flicd -d -f /etc/flicd/flic.db -s 0.0.0.0 -l /var/log/flicd.log -w EnvironmentFile=-/etc/default/flicd [Install] WantedBy=multi-user.target ```
flicd logfile ``` Available HCI devices found: Trying hci0 Flic server is now up and running! Entering daemon state... Entered daemon state. Received signal 15 Exited ```
systemctl status flicd ``` root@rpi3:~# systemctl status flicd ● flicd.service - flicd Service Loaded: loaded (/etc/systemd/system/flicd.service; enabled; vendor preset: enabled) Active: inactive (dead) since Fri 2019-05-10 08:10:49 EDT; 3min 16s ago Process: 278 ExecStart=/usr/local/bin/flicd -d -f /etc/flicd/flic.db -s 0.0.0.0 -l /var/log/flicd.log -w (code=exited, status=0/SUCCESS) Main PID: 278 (code=exited, status=0/SUCCESS) May 10 08:10:49 rpi3 systemd[1]: flicd.service: Changed dead -> running May 10 08:10:49 rpi3 systemd[1]: flicd.service: Job flicd.service/start finished, result=done May 10 08:10:49 rpi3 systemd[1]: Started flicd Service. May 10 08:10:49 rpi3 systemd[278]: flicd.service: Executing: /usr/local/bin/flicd -d -f /etc/flicd/flic.db -s 0.0.0.0 -l /var/log/flicd.log -w May 10 08:10:49 rpi3 systemd[1]: flicd.service: Child 278 belongs to flicd.service May 10 08:10:49 rpi3 systemd[1]: flicd.service: Main process exited, code=exited, status=0/SUCCESS May 10 08:10:49 rpi3 systemd[1]: flicd.service: Changed running -> stop-sigterm May 10 08:10:49 rpi3 systemd[1]: flicd.service: Child 314 belongs to flicd.service May 10 08:10:49 rpi3 systemd[1]: flicd.service: cgroup is empty May 10 08:10:49 rpi3 systemd[1]: flicd.service: Changed stop-sigterm -> dead ```
Emill commented 5 years ago

With Type=simple, I think systemd expects the process not to fork. So either remove the -d option, or set Type=forking.

See https://www.freedesktop.org/software/systemd/man/systemd.service.html#Options for more info.

aboulfad commented 5 years ago

Doh ... thats what happens when we blindly copy and paste ! I tried it and of course it works. Thank you for the prompt help (I take back what I said in #84 :-) )

PS: since I have your attention, it would be greatly appreciated if you can provide some hints for issue #84