ZeroPhone / ZPUI

Official ZeroPhone UI framework, based on pyLCI
http://zpui.rtfd.org/
Apache License 2.0
79 stars 19 forks source link

Check if another instance of ZPUI is running #120

Open piajesse opened 5 years ago

piajesse commented 5 years ago

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

CRImier commented 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.

piajesse commented 5 years ago

could we add that to avoid someone trying to run 2 instances at the same time?

CRImier commented 5 years ago

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

piajesse commented 5 years ago

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

CRImier commented 5 years ago

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 =)

piajesse commented 5 years ago

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...

CRImier commented 5 years ago

hmm. Could you debug the service file?

CRImier commented 5 years ago

As in, how to force systemd to create it

piajesse commented 5 years ago

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

CRImier commented 5 years ago

hmm, sounds like a good workaround