문제

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