سؤال

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

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top