You are not logged in.

#1 2016-10-20 22:38:16

Archie5000
Member
Registered: 2015-05-10
Posts: 7

Does systemd kill my program because it found error messages in log?

Hi,

I have a small program that does not fork.
I start this program via systemd:

[Unit]
Description=jobqueue

[Service]
ExecStart=/home/jobq1
Restart=always
RestartSec=5
WorkingDirectory=/home
Type=simple

[Install]
WantedBy=multi-user.target

My program talks to a usb device.
My problem is: As soon as I disconnect the USB from the computer, my jobqueue program terminates.
I think systemd scans the logfiles because I find there a expectable ftdi error that complains about the USB disconnect. This log-entry is in red color.

jobq1 kernel: ftdi_sio ttyUSB0: usb_serial_generic_read_bulk_callback - urb stopped: -32

Running my program on the console by hand does not exit when I disconnect the USB-cable. My program is prepared of usb disconnects.

So I suspect systemd is killing my program because it thinks it has found a problem found in the logfile.

How can I stop this behavior?


Thank you!

Archie

Offline

#2 2016-10-20 22:44:47

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,774

Re: Does systemd kill my program because it found error messages in log?

No, it does not scan the log looking for errors as a precursor to killing things.

Edit:  Your service file looks reasonable, I would expect it to restart after 5 seconds.   Are you running this at the user level or the system level ?  How about when you run it by hand?  What are the owner, group and permissions on the device node of the USB device?  Are there any files in /home that are needed by the process? who owns them?

Edit2:  Can you share the program?

Last edited by ewaller (2016-10-20 22:56:36)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2016-10-20 23:04:49

Archie5000
Member
Registered: 2015-05-10
Posts: 7

Re: Does systemd kill my program because it found error messages in log?

Thank you for your answer.

I think it might have to do with KillUserProcesses=yes and systemd thinks the USB-unplug is a user-disconnect?

Offline

#4 2016-10-20 23:06:39

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,774

Re: Does systemd kill my program because it found error messages in log?

Seems reasonable.  You should experiment with that.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#5 2016-10-20 23:31:08

Archie5000
Member
Registered: 2015-05-10
Posts: 7

Re: Does systemd kill my program because it found error messages in log?

Sorry, just answered, did not read your edited text. The thing is that on a ps aux the tty is "?", when I plug the usb in it is suddenly ttyUSB0 and I think the unplug kills it then. But  KillUserProcesses=no (plus reboot to be sure) in logind.conf doesn't help. Is there a way to assign the program another tty before so it does not look for ttyUSB0?

Edit: Running by hand works flawless, jobqueue runs as root, jobq-service is in /etc/systemd/system dir.

Last edited by Archie5000 (2016-10-20 23:32:32)

Offline

#6 2016-10-21 11:42:49

Archie5000
Member
Registered: 2015-05-10
Posts: 7

Re: Does systemd kill my program because it found error messages in log?

It definitively has to do with systemd because when I start the program using systemd with setsid so that the jobqueue-program loses its status as being a process "descendant", then the program continues to run, becuase systemd is no longer aware that the program is the one to check permanently.

Offline

Board footer

Powered by FluxBB