Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. A Ruby script can be run as a Windows Service using FireDaemon Pro, which allows you to have the script start automatically at boot prior to login, start multiple instances of the script and more. This HOWTO will show you how to set it up. You can also use FireDaemon Fusion to manage FireDaemon and other Windows services via a web browser.
Ruby Setup Under FireDaemon Pro
Download the latest Ruby Installer from here. Ruby Installer is the Windows distribution of Ruby.
When installing Ruby, make sure all 3 checkboxes are checked to prevent any possible issues with running scripts.
By default Ruby installs to C:\Ruby### with ### denoting version. For the purposes of this HOWTO, we will use that directory, which at time of this writing is C:\Ruby200.
Ruby has many executables that you can use, but the one you would use for most scripts is "ruby.exe"
After installing Ruby, be sure to test your Ruby script by running it at a command prompt. If your script doesn't work here, it won't work as a Windows service.
Download and install FireDaemon Pro into the directory of your choice, typically C:\Program Files\FireDaemon.
Next start the FireDaemon GUI from the desktop shortcut. Click on the "Create a new service definition" button in the toolbar (or type Ctrl+N) and enter the information into the fields as you see below. Adjust the paths to suit your installation. Note the required parameters.
- For Executable, point it to ruby.exe
- For Working Directory, point it to the directory in which your Ruby script resides.
- For Parameters, enter the name of your Ruby script including its extension (e.g. script.rb)
Now click on the Settings tab. If you DON'T want to see the Ruby script running, uncheck the Interact with Desktop check box & select "Hidden" from the "Show Window" dropdown. You must set the job type to "Global" so that child processes are terminated properly when the service is stopped or restarted. You can optionally run the Ruby script as the user you installed it as. You can change the Process Priority to allocate more CPU time to your Ruby script or specify which CPU or core the Ruby script will run on (in the case of multi-processor, hyperthreaded or multi-core CPUs).
Now click on the Lifecycle tab. Uncheck Graceful Shutdown as it can slow the shutdown of the Ruby script. Make sure "Console Application" is checked.
Now click on the OK button to install and start your Ruby script!