After startup of system my script starts from crontab as daemon. It works for a while and suspends/hangs without response. After that I cannot run it like sudo python script.py restart
, because it says:
File "/usr/lib/pymodules/python2.7/daemon/runner.py", line 149, in _stop
"PID file %(pidfile_path)r not locked" % vars())
daemon.runner.DaemonRunnerStopFailureError: PID file '/home/pi/testdaemon.pid' not locked
In init from script there is:
def __init__(self):
self.stdin_path = '/dev/null'
self.stdout_path = '/dev/null'
self.stderr_path = '/dev/null'
self.pidfile_path = '/home/pi/testdaemon.pid'
self.pidfile_timeout = 5
Any idea of solving this problem would be great!
EDIT:
It seems that I have found my problem. I couldn't restart daemon when it stopped because whole mechanism wanted to stop my daemon at first place and it couldn't because it was already stopped. Then I found out that there was an issue inside my script which made whole run only for a few seconds and crash. Anyway, thank you for every answers!