[FreeBSD] unicorn.god
I had a very strange problem concerning my Ruby on Rails installation, using FreeBSD, nginx, Unicorn and God.
When starting god from the command line as root, everything worked. However, as soon as I placed the god command into /etc/rc.local or a even service file in /usr/local/etc/rc.d, god didn’t start the Unicorn server but showed exit code 127 for “bundle exec unicorn -E production -c config/unicorn.rb”.
So I added a log directive to the god configuration and looked at the log file. It said:
env: ruby1.9: No such file or directory
Then I changed the god configuration to include /usr/local/bin in the PATH and now everything works. Here my configuration file:
RAILS_ROOT = '/srv/www/my-project-prod/current'
God.watch do |w|
w.name = 'my-project'
w.interval = 30.seconds
w.uid = 'my-project'
w.gid = 'my-project'
w.pid_file = File.join(RAILS_ROOT, "tmp/pids/unicorn.pid")
w.behavior(:clean_pid_file)
w.dir = RAILS_ROOT
w.env = { 'PATH' => '/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin' }
w.start = "bundle exec unicorn -E production -c config/unicorn.rb -D"
w.stop_signal = 'QUIT'
w.restart = "kill -USR2 `cat #{w.pid_file}`"
w.start_grace = w.restart_grace = 30
w.start_if do |start|
start.condition(:process_running) do |c|
c.running = false
end
end
end
If somebody is interested, here is my god service file (/usr/local/etc/rc.d/god):
#!/bin/sh
#
# PROVIDE: god
# REQUIRE: DAEMON
. /etc/rc.subr
name="god"
rcvar=`set_rcvar`
command="/usr/local/bin/god"
start_cmd='${command} -c /usr/local/etc/god.conf'
status_cmd='${command} status'
stop_cmd='${command} terminate'
load_rc_config $name
run_rc_command "$1"
Where god_enable=”YES” is set in /etc/rc.conf, and /usr/local/etc/god.conf includes all my project god files.
6 Notes/ Hide
-
yeseniauio09 likes this
-
rfc2822 posted this