Open piajesse opened 5 years ago
We do have a pidfile already, too: PIDFile=/run/zpui.pid
(from the .service file) However, it obviously isn't used when we run ZPUI as sudo python main.py
.
could we add that to avoid someone trying to run 2 instances at the same time?
Sure, that's doable - no idea how exactly yet, but sure, why not. I'd suggest a warning more than "refuse to start", I'd rather not make this into something that developers would have to fight in case of a bug with detection mechanism
I meant for it to pause at start asking if you wanted to continue anyways, try to top the other PID, or just close We could also add a starting argument like --ignore-pid to avoid this check :D
not sure about an argument - don't want anyone to run "main.py --help" to figure out a bug. A pause on start sounds more dev-friendly =)
so I see the line that says to use /run/zpui.pid
in /etc/systemd/system/zpui.service
but when it start the ui via systemctl start zpui
it start up and works and doesn't create a pid file in said location...
hmm. Could you debug the service file?
As in, how to force systemd to create it
Actually I will set it up that when it checks It will just create a file if it doesn't exist, and if it does exist and its the same pid as the current running version, it will just continue
hmm, sounds like a good workaround
How
At start up, check if there there is a PID file at
/tmp/zpui.pid
, and if there is check if the number inside the files PID is still running, if it is, then fail to start if no console, and if there is a console say another instance is still running and ask if they want to quit or try again. and if its running, say a warning and then overwrite with that processes PID is still there and that most likely means a failed shutdown, and then start like normal