Forked from sfgeorge/adhearsion-jruby-startup.rb
Created
April 13, 2014 05:55
Revisions
-
sfgeorge created this gist
Apr 12, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ # Start Adhearsion in JRuby, while building a pidfile as soon as possible. def ahnctl_start shell_command = "#{exec_ahn_async} && #{wait} && #{save_pid}" %x{shell_command} end private # Run start in the background, since it is not daemonized. # This also makes it easier for us to nab the PID. def exec_ahn_async "( #{exec_ahn} & )" end # Start Adhearsion def exec_ahn exec_ahn = 'rvm $(cat .ruby-version) exec bundle exec ahn start .' # Add action-specific options to the invoked command exec_ahn << ' --no-console' end # Wait a moment to ensure that Java has spawned. def wait 'sleep 1' end # Save the process id / PID def save_pid pid_file = '/path/to/adhearsion.pid' "ps -fp $(/sbin/pidof java) | grep 'ahn start' | awk '{print $2}' > #{pid_file}" end