/srv/irclogs.ubuntu.com/2015/01/06/#upstart.txt

=== Cidan is now known as zz_Cidan
mattzubaHoping someone can help real quick... I'm trying to write an upstart job to start up a daemon, but the daemon requires to be run under a different user.  I'm running on AWS EC2 with upstart 0.6.5, so I can't use setuid/setgid, and sudo/su isn't working (Terminated with status 1).  I can paste my script if needed15:31
jodhmattzuba: just read http://upstart.ubuntu.com/cookbook/#run-a-job-as-a-different-user15:33
mattzubaI've used a few of those suggestions, but they haven't worked.  I have to source a script prior to running the daemon to setup some environment variables, so I'm using a script stanza.  I've used various versions of those exec calls and they all fail to stay running.  I can't use start-stop-daemon since it's not available either.15:34
mattzubascript15:35
mattzuba    . /opt/elasticbeanstalk/support/envvars15:35
mattzuba    sudo -Eu webapp /var/app/current/artisan queue:work --daemon --tries=3 --sleep=515:35
mattzubaend script15:35
mattzubathe sudo line works fine when I run it on the command line, but not via upstart15:35
mattzubai tried putting exec in front of sudo as well with the same results15:35
jodhmattzuba: in which case, you'll want to look at http://upstart.ubuntu.com/cookbook/#see-the-environment-a-job-runs-in and http://upstart.ubuntu.com/cookbook/#checking-how-a-service-might-react-when-run-as-a-job. Also, presumably you're using 'sudo -E'?15:45
jodhmattzuba: ah - sorry, yes you are :)15:45
mattzubathanks, I'll take a read over those. The cookbook has lots of great info, just wish it was easier for a Upstart newb like me to parse through, heh15:46
jodhmattzuba: try using my procenv tool as you can diff the output. It's covered in the links above. Changes are the problem is that when upstart runs your job, key env vars are not set. Note: http://upstart.ubuntu.com/cookbook/#job-environment15:47
mattzubacool.  the only envvars I need are custom ones set in the elastic beanstalk support envvars file, nothing special to the system that I can think of anyway15:48
mattzubagot it!!!16:00
mattzubathis seemed to work, the only one I hadn't tried yet: exec su -s /bin/sh -c 'exec "$0" "$@"' webapp -- /var/app/current/artisan queue:work --daemon16:02
=== zz_Cidan is now known as Cidan
=== Cidan is now known as zz_Cidan
=== broder_ is now known as broder
=== zz_Cidan is now known as Cidan

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!