I am currently running Foreman on staging (Ubuntu) and once I get it working will switch to using upstart.
My Procfile.staging looks like this:
nginx: sudo service nginx start
unicorn: bundle exec unicorn -c ./config/unicorn.rb
redis: bundle exec redis-server
sidekiq: bundle exec sidekiq -v -C ./config/sidekiq.yml
I can successfully start nginx using:
$ sudo service nginx start
However when I run $ foreman start
, whilst the other three processes start successfully, nginx does not:
11:15:46 nginx.1 | started with pid 15966
11:15:46 unicorn.1 | started with pid 15968
11:15:46 redis.1 | started with pid 15971
11:15:46 sidekiq.1 | started with pid 15974
11:15:46 nginx.1 | Starting nginx: nginx.
11:15:46 nginx.1 | exited with code 0
11:15:46 system | sending SIGTERM to all processes
SIGTERM received
11:15:46 unicorn.1 | terminated by SIGTERM
11:15:46 redis.1 | terminated by SIGTERM
11:15:46 sidekiq.1 | terminated by SIGTERM
So why isn't nginx starting when started by Foreman?
The is a problem in your Procfile.
The nginx
command can't use sudo
inside foreman
, because it will always ask for a password
and then it will fail. That's why you are not starting nginx
and the logs are empty.
If you really need to use sudo inside a procfile you could use something like this:
sudo_app: echo "sudo_password" | sudo -S app_command
nginx: echo "sudo_password" | sudo -S service nginx start
which I really don't recommend. Other option is to call sudo foreman start
For more information check out this issue on github, it is precisely what you want to solve.
Keep me posted if it works for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With