Need help running Python app as service in Ubuntu with Upstart

后端 未结 1 721
悲&欢浪女
悲&欢浪女 2021-02-04 08:56

I have written a logging application in Python that is meant to start at boot, but I\'ve been unable to start the app with Ubuntu\'s Upstart init daemon. When run from the term

相关标签:
1条回答
  • 2021-02-04 09:34

    Thanks to unutbu's help, I have been able to correct my job. Apparently, these are the only environment variables that Upstart sets (retrieved in Python with os.environ):

    {'TERM': 'linux', 'PWD': '/', 'UPSTART_INSTANCE': '', 'UPSTART_JOB': 'greeenlog', 'PATH': '/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin'}
    

    My program relies on a couple of these variables being set, so here is the revised job with the right environment variables:

    # greeenlog
    
    description     "I log stuff."
    
    start on startup
    stop on shutdown
    
    env DISPLAY=:0.0
    env GTK_RC_FILES=/etc/gtk/gtkrc:/home/greeenguru/.gtkrc-1.2-gnome2
    
    script
        exec /usr/local/greeenlog/main.pyw > /tmp/greeenlog.out 2>&1
    end script
    

    Thank you!

    0 讨论(0)
提交回复
热议问题