Reputation: 168
I am trying to export upstart scripts from my rails application using foreman but I don't want to use sudo to do that.
I saw that the Ubuntu 12.04 that I am using supports userjob http://upstart.ubuntu.com/cookbook/#user-job so I have enabled that. It was enabled successfully with a test script that I have placed at ~/.init
so I tried bundle exec foreman export upstart ~/.init -a myapp -l log -u myuser
and it exported all my foreman tasks to ~/.init.
Now when I run start myapp
it works however my thin instances simply doesn't start and I can't figure out why. Maybe it has something to do with using a RVM user install. Is there a way to debug this? Thanks.
Upvotes: 1
Views: 722
Reputation: 481
You can set
console log
in your upstart script, and the output should be shown in a log-fie.
According to the recen upstart cookbook, session job output will appear in $XDG_CACHE_HOME/upstart/<jobname>
, (which should fall back to $HOME/.cache
).
Alternatively, you can tell it to log elsewhere, with the --logdir
option to the upstart command.
Since your question is a few months old, you may already be aware that using $HOME/.init
for "user" jobs is deprecated in favour of $XDG_CONFIG_HOME/upstart
(or $HOME/.config/upstart/
). Looks like the latest Foreman doesn't give nice defaults for that, though it's still possible.
As for the reason your script won't start, some things to consider are
setuid <user>
bundle
in this environment?I'm not sure about RVM, but I've had some success with chruby. Here's an example (which logs):
description "A Rails application"
author "Me ([email protected])"
start on runlevel [2345]
stop on runlevel [016]
respawn
setuid appuser
setgid appuser
console output
chdir /var/www/app/current
exec chruby-exec 2.0 -- bundle exec unicorn_rails -E production -P 5000
Upvotes: 1