Mo J. Mughrabi Mo J. Mughrabi - 1 year ago 169
Python Question

start a background process with nohup using fabric

am trying to start a celerycam process using fabric using the below nohup command. Unfortunately, nothing is happening, manually using the same command i could start the process but not through fabric. Any advise on how i can solve this?

def start_celerycam():
'''Start celerycam daemon'''
with cd(env.project_dir):
virtualenv('nohup bash -c "python celerycam --logfile=%scelerycam.log &> %scelerycam.nohup &> %scelerycam.err" &' % (env.celery_log_dir,env.celery_log_dir,env.celery_log_dir,env.celery_log_dir))

Answer Source

I'm using Erich Heine's suggestion to use 'dtach' and it's working pretty well for me:

def runbg(cmd, sockname="dtach"):
    return run('dtach -n `mktemp -u /tmp/%s.XXXX` %s'  % (sockname,cmd))

This was found here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download