Ruby, Cocoa, Mac OS X and things of my not so exciting life.
FreeBSD Startup Script With Ruby
Since some days ago I’ve been using FreeBSD in a Rails deployment server configuring it to use Capistrano, nginx and mongrel but then I wanted my mongrel instances to be run at startup and what I found was this message:
Put your .sh script at /usr/local/etc/rc.d
And since I like ruby, I began to code my script with it and the problems came:
env: ruby: No such file or directory
custom_require.rb:27: command not found: mongrel_rails
First, here is my final code that was inspired by Tim Morgan’s:
The key part is the ENV[“PATH”] setup, that line is needed as FreeBSD’s PATH at startup is “/sbin:/bin:/usr/sbin:/usr/bin” and this also leads us to change the interpreter path from something like “#!/usr/bin/env ruby” to “#!/usr/local/bin/ruby”, i.e. its full path.
That’s all, now our ruby script really runs at startup time without complaining.