rfc2822's blog

  • Archive
  • RSS
  • Contact me

[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.

    • #freebsd
    • #rails
  • 1 year ago
  • 6
  • Comments
  • Permalink
Share

Short URL

TwitterFacebookPinterestGoogle+

6 Notes/ Hide

  1. yeseniauio09 likes this
  2. rfc2822 posted this

Recent comments

Blog comments powered by Disqus
← Previous • Next →

Logo

Pages

  • Author

Me, Elsewhere

  • rfc2822 on github

Following

  • helmeloh
  • kaltspiegel
  • riverart
  • doki66
  • staff
  • max-weller
  • oivoodoo
  • patrickonline
  • briilestinkt

I Dig These Posts

See more →
  • Photoset via huatunan

    色彩鹦鹉。color parrot
    Photoset via huatunan
  • Photo via androgynyous

    markrabadan:

    ASH STYMEST for OPEN LAB by MARK RABADAN.

    Photo via androgynyous
  • Photo via androgynyous
    Photo via androgynyous
  • Photo via kaltspiegel

    Bin bei meinen Eltern, hab bis Nachmittags gepennt und finde das in der Küche. Es sind die kleinen Dinge. <3

    Photo via kaltspiegel
  • Photo via riverart

    Looks like these guys turned my note 10.1 into a proper wireless wacom tablet.

    No lag, just fun. Check them out and donate if you like it :)

    Photo via riverart
  • RSS
  • Random
  • Archive
  • Contact me
  • Mobile

This content is licensed under the Creative Commons Attribute 3.0 Unported (CC BY 3.0) license.

Effector Theme by Pixel Union