Skip to content

Instantly share code, notes, and snippets.

@kaworu
Created May 13, 2015 08:31
Show Gist options
  • Save kaworu/a0f158e85f51f6705574 to your computer and use it in GitHub Desktop.
Save kaworu/a0f158e85f51f6705574 to your computer and use it in GitHub Desktop.
#!/bin/sh
datadir="/home/huongviet.ch/ror"
daemon="/usr/local/bin/unicorn_rails18"
daemon_flags="--host :: --port 8000 --env production --debug --daemonize"
daemon_user="huongviet.ch"
. /etc/rc.d/rc.subr
pexp="ruby18: unicorn_rails18 master.*"
rc_start() {
${rcexec} "cd ${datadir} && env LD_PRELOAD=libpthread.so ${daemon} ${daemon_flags}"
}
rc_cmd $1
@kaworu
Copy link
Author

kaworu commented May 13, 2015

% sudo sh -x /etc/rc.d/unicorn_rails -d check
+ datadir=/home/huongviet.ch/ror
+ daemon=/usr/local/bin/unicorn_rails18
+ daemon_flags=--host :: --port 8000 --env production --debug --daemonize
+ daemon_user=huongviet.ch
+ . /etc/rc.d/rc.subr
+ [ -n  ]
+ [ -n /usr/local/bin/unicorn_rails18 ]
+ unset _RC_DEBUG _RC_FORCE
+ getopts df c
+ _RC_DEBUG=-d
+ getopts df c
+ shift 1
+ basename /etc/rc.d/unicorn_rails
+ _name=unicorn_rails
+ _RC_RUNDIR=/var/run/rc.d
+ _RC_RUNFILE=/var/run/rc.d/unicorn_rails
+ _rc_do _rc_parse_conf
doing _rc_parse_conf
doing _rc_quirks
+ eval _rcflags=${unicorn_rails_flags}
+ _rcflags=
+ eval _rcuser=${unicorn_rails_user}
+ _rcuser=
+ eval _rctimeout=${unicorn_rails_timeout}
+ _rctimeout=
+ getcap -f /etc/login.conf unicorn_rails
+ > /dev/null 
+ 2>&1 
+ [ -z  ]
+ daemon_class=daemon
+ [ -z huongviet.ch ]
+ [ -z  ]
+ daemon_timeout=30
+ [ -n  ]
+ [ -n  ]
+ [ -n  ]
+ [ -n  ]
+ [ -n -d ]
+ echo -n unicorn_rails_flags 
unicorn_rails_flags + [ -n  ]
+ echo -n empty, using default 
empty, using default + echo >--host :: --port 8000 --env production --debug --daemonize<
>--host :: --port 8000 --env production --debug --daemonize<
+ readonly daemon_class
+ unset _rcflags _rcuser _rctimeout
+ pexp=/usr/local/bin/unicorn_rails18 --host :: --port 8000 --env production --debug --daemonize
+ rcexec=su -l -c daemon -s /bin/sh huongviet.ch -c
+ pexp=ruby18: unicorn_rails18 master.*
+ rc_cmd check
doing _rc_read_runfile
unicorn_rails
doing rc_check
(failed)

@kaworu
Copy link
Author

kaworu commented May 13, 2015

After applying the following patch:

--- unicorn_rails.old Wed May 13 13:33:00 2015
+++ unicorn_rails       Wed May 13 13:33:27 2015
@@ -14,4 +14,8 @@
        ${rcexec} "cd ${datadir} && env LD_PRELOAD=libpthread.so ${daemon} ${daemon_flags}"
 }

+rc_check() {
+       echo ${pexp} > /tmp/rc_check
+}
+
 rc_cmd $1

I have:

% sudo sh -x /etc/rc.d/unicorn_rails -d check                                                                                                                                                          
+ datadir=/home/huongviet.ch/ror
+ daemon=/usr/local/bin/unicorn_rails18
+ daemon_flags=--host :: --port 8000 --env production --debug --daemonize
+ daemon_user=huongviet.ch
+ . /etc/rc.d/rc.subr
+ [ -n  ]
+ [ -n /usr/local/bin/unicorn_rails18 ]
+ unset _RC_DEBUG _RC_FORCE
+ getopts df c
+ _RC_DEBUG=-d
+ getopts df c
+ shift 1
+ basename /etc/rc.d/unicorn_rails
+ _name=unicorn_rails
+ _RC_RUNDIR=/var/run/rc.d
+ _RC_RUNFILE=/var/run/rc.d/unicorn_rails
+ _rc_do _rc_parse_conf
doing _rc_parse_conf
doing _rc_quirks
+ eval _rcflags=${unicorn_rails_flags}
+ _rcflags=
+ eval _rcuser=${unicorn_rails_user}
+ _rcuser=
+ eval _rctimeout=${unicorn_rails_timeout}
+ _rctimeout=
+ getcap -f /etc/login.conf unicorn_rails
+ > /dev/null 
+ 2>&1 
+ [ -z  ]
+ daemon_class=daemon
+ [ -z huongviet.ch ]
+ [ -z  ]
+ daemon_timeout=30
+ [ -n  ]
+ [ -n  ]
+ [ -n  ]
+ [ -n  ]
+ [ -n -d ]
+ echo -n unicorn_rails_flags 
unicorn_rails_flags + [ -n  ]
+ echo -n empty, using default 
empty, using default + echo >--host :: --port 8000 --env production --debug --daemonize<
>--host :: --port 8000 --env production --debug --daemonize<
+ readonly daemon_class
+ unset _rcflags _rcuser _rctimeout
+ pexp=/usr/local/bin/unicorn_rails18 --host :: --port 8000 --env production --debug --daemonize
+ rcexec=su -l -c daemon -s /bin/sh huongviet.ch -c
+ pexp=ruby18: unicorn_rails18 master.*
+ rc_cmd check
doing _rc_read_runfile
unicorn_rails
doing rc_check
(ok)
% cat /tmp/rc_check 
/usr/local/bin/unicorn_rails18 --host :: --port 8000 --env production --debug --daemonize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment