Note that there are some explanatory texts on larger screens.

plurals
  1. POStart bundle executable on bootup (Mac OSX/)
    text
    copied!<p>I'm trying to setup a Mac OSX system as a server, and would like my rails application to start at bootup, including all dependent applications. I've managed to get passenger/nginx and redis to start, but am having trouble with starting sidekiq.</p> <p>More specifically, I would like to run this command at startup <code>bundle exec sidekiq -q carrierwave -e production -P /path/to/pid_file</code>. </p> <p>I've tried creating the following plist file and adding it to /System/Library/LaunchDaemons/.</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt; &lt;plist version="1.0"&gt; &lt;dict&gt; &lt;key&gt;Debug&lt;/key&gt; &lt;true/&gt; &lt;key&gt;KeepAlive&lt;/key&gt; &lt;true/&gt; &lt;key&gt;Label&lt;/key&gt; &lt;string&gt;my.sidekiq&lt;/string&gt; &lt;key&gt;ProgramArguments&lt;/key&gt; &lt;array&gt; &lt;string&gt;/Users/username/.rvm/gems/ruby-1.9.3-p194@global/bin/bundle&lt;/string&gt; &lt;string&gt;exec&lt;/string&gt; &lt;string&gt;sidekiq&lt;/string&gt; &lt;string&gt;-q&lt;/string&gt; &lt;string&gt;carrierwave&lt;/string&gt; &lt;string&gt;-e&lt;/string&gt; &lt;string&gt;production&lt;/string&gt; &lt;string&gt;-P&lt;/string&gt; &lt;string&gt;/path/to/sidekiq.pid&lt;/string&gt; &lt;/array&gt; &lt;key&gt;EnvironmentVariables&lt;/key&gt; &lt;dict&gt; &lt;key&gt;RAILS_ENV&lt;/key&gt; &lt;string&gt;production&lt;/string&gt; &lt;/dict&gt; &lt;key&gt;WorkingDirectory&lt;/key&gt; &lt;string&gt;/path/to/rails/project&lt;/string&gt; &lt;key&gt;StandardOutPath&lt;/key&gt; &lt;string&gt;/path/to/log/sidekiq.log&lt;/string&gt; &lt;key&gt;StandardErrorPath&lt;/key&gt; &lt;string&gt;/path/to/log/sidekiq_err.log&lt;/string&gt; &lt;key&gt;RunAtLoad&lt;/key&gt; &lt;true/&gt; &lt;/dict&gt; &lt;/plist&gt; </code></pre> <p>I run <code>sudo launchctl load /System/Library/LaunchDaemons/my.sidekqi.plist</code> to load and start the daemon, but the system console shows an exit code 127 for this launchd (and repeatedly tries to restart). </p> <p>If I run the program arguments from the command line, I get a "Gemfile not found" error (assuming I'm not in the rails project dir). If I run from the project dir, sidekiq will start. From what I understand, WorkingDirectoy should execute the bundle command within the specified path (which is my rails project path). </p> <p>I believe the problem stems from bundle not being executed within the rails project directory. So either I need to get launchd to start the process in the working directory (which isn't working for some reason) or execute the bundle command outside of the project directory but somehow instructing it where the gem file resides.</p> <p>I'm also using rvm, if this matters. ruby 1.9.3, rails 3.2.13, mac osx lion.</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload