Fabric problems with reloading supervisor on remote host
-
03-07-2021 - |
Question
My project is hosted on Webfaction and supervisor is used to be aware of processes. I use shell utils to get the PID of supervisor and it works just fine when I do it manually, but I got random PIDs when executing the same command remotely with Fabric
Code to get PID of supervisor
spid = run('ps auxw | grep supervisord | grep %s | tr -s \' \' | cut -d\ -f 2' % USER)
if spid: # if supervisor is running and PID is found
run('kill %s' % spid) # kill supervidor daemon
I'm confused why I get random PIDs when calling command remotely, what is wrong with the way I do it?
Thanks,
Sultan
Solution
You could solve this simpler by using pkill
or pgrep
to find the pid. But also if that's all you're doing I'd say use the -j|--pidfile=
option so you don't have to look it up through the process output.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow