0

I have a python script that I have written. It works perfectly as intended when I run ./myscript.py and does not error out, continues to work for days until I shut it off manually.

I have also created a SystemD service written for my python script. However, when running the service it will error out halfway through every other round. SystemD restarts the script and it works perfectly for 1 round and errors half way through.

Here is the error from journalctl -xe -f:

Jul 05 16:04:35 glas-dev systemd[1]: magewelk.service: Start 
operation timed out. Terminating.
Jul 05 16:04:35 glas-dev magewelk.py[9685]:       
Jul 05 16:04:35 glas-dev systemd[1]: magewelk.service: Main process 
exited, code=dumped, status=3/QUIT
Jul 05 16:04:35 glas-dev systemd[1]: Failed to start Data collector 
Magewell to Elasticsearch.
-- Subject: Unit magewelk.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-
devel
-- 
-- Unit magewelk.service has failed.
-- 
-- The result is failed.
Jul 05 16:04:35 glas-dev systemd[1]: magewelk.service: Unit entered 
failed state.
Jul 05 16:04:35 glas-dev systemd[1]: magewelk.service: Failed with 
result 'core-dump'.
Jul 05 16:04:35 glas-dev systemd[1]: magewelk.service: Service hold-
off time over, scheduling restart.
Jul 05 16:04:35 glas-dev systemd[1]: Stopped Data collector Magewell 
to Elasticsearch.
-- Subject: Unit magewelk.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-
devel
-- 
-- Unit magewelk.service has finished shutting down.
Jul 05 16:04:35 glas-dev systemd[1]: Starting Data collector Magewell 
to Elasticsearch...
-- Subject: Unit magewelk.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-
devel
-- 
-- Unit magewelk.service has begun starting up.

The magewelk.service file is as follows:

[Unit]
Description=Data collector Magewell to Elasticsearch
After=syslog.target

[Service]
WorkingDirectory=/opt/labglas_streamer
ExecStartPre=/bin/bash -c 'chown -R charter:www-data 
/opt/labglas_streamer'
ExecStart=/opt/labglas_streamer/magewelk.py
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all

[Install]
WantedBy=multi-user.target

The script is single threaded with error catches. I am not getting any errors from the script.

This is on an Ubuntu 16.04.2 LTS server. I have watched the memory when the service crashes, the net connections, the processors and have not seen anything that stands out.

lzukel
  • 1
  • 1

1 Answers1

1

You probably want "simple" as the type instead of "notify". Notify only works if your python script knows how to notify systemd.

Dylan Martin
  • 538
  • 4
  • 13