I have an Ubuntu 14 server where I run a Ruby on Rails app and I want to create a service that will start the rails server automatically on reboot. This service should allow me to run the Puma server in background, as a daemon process.
Up until a later apt-get update & apt-get upgrade
I was able to run:
bundle exec puma -C config/puma.rb -b unix:/home/appname/site/shared/tmp/sockets/appname-puma.sock -d
The -d
(daemon) allowed me to run the process in background but now this flag is not available anymore. Puma won't start if I add the: -d
flag when I start the server.
Following this tutorial: https://gist.github.com/0x263b/683c5d09b1cbf4240884491696eb5e46
I created the following file: /etc/ini/puma-manager.conf
description "Manages the set of puma processes"
# This starts upon bootup and stops on shutdown
start on runlevel [2345]
stop on runlevel [06]
pre-start script
logger -t "puma-manager" "Starting Rails APP"
cd /home/appname/site/current
exec bundle exec puma -C config/puma.rb -b unix:/home/appname/site/shared/tmp/sockets/appname-puma.sock
end script
When I run: service puma-manager start
I receive the following error: Job failed to start
I also tried to run with sudo but I receive the same message.
In: /var/log/upstart/puma-manager.log
I see the error:
/proc/self/fd/9: 4: cd: can't cd to /home/appname/site/current
Even if I entered a different valid path for cd, I have the same error.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…