-
Notifications
You must be signed in to change notification settings - Fork 0
Home
In the etc/tools folder under trunk is a script file called main.rb it is used to run a RubyService derived class outside of the service wrapper stuff.
in order to invoke the service you can copy the main.rb file to your service directory and just type:
jruby main.rb -service_file demo_service
There is one caveat in that the \-service_file name argument must classify into your service class name. So if you pass demo_service the script assumes that file contains a class called DemoService.
- The Service Wrapper is implemented in Java and works with Java (and JRuby) applications.
- the Service Wrapper is OS “independent” (well the deployment scenario for each os is different but your code doesn’t change)
here are the steps you need to take to use the service wrapper
Do this at :
Once you generate it you will be given a snippet for a wrapper configuration file.
Setting up the wrapper involves copying some files to your application’s launch directory, creating a configuration file, and creating a launch script. The wrapper files you need to copy are the wrapper executable and an os dependent library to your application’s directory. See the DemoSerivce directory and you will find a subdirectory for each platform, in these directories are the wrapper executable, configuration file, and library files you need for that specific platform.
If you are experimenting with the DemoService copy the contents of the os platform directory you are testing on up to the main application directory. At this point you should be able to launch the services by invoking the wrapper executable.
Also in the application directory is a script called demo. This script is based on a Wrapper file called sh.script.in this script is used to detect your OS and properly launch the wrapper either as a service, or in console mode (amongst other things).
In order to avoid duplication… this set of links gets you there: http://wrapper.tanukisoftware.org/doc/english/launch.html
In the wrapper.conf file you need to setup the paths so that the wrapper can find the jars your app requires (if any), the location of the wrapper.dll (or os equivalent) file is located, and most importantly the location of JRuby home needs to be passed as a java argument:
wrapper.java.additional.1=-Djruby.home=/absolute/path/to/jruby
Alternatively you can use the JRUBY_PATH environment variable to specify the jruby location. Like this:
wrapper.java.additional.1=-Djruby.home=%JRUBY_HOME%
In the configuration file we pass the command line arguments for invoking our service:
Application parameters. Add parameters as needed starting from 1
wrapper.app.parameter.1=-fn
wrapper.app.parameter.2=demo_service
wrapper.app.parameter.3=-cn
wrapper.app.parameter.4=DemoService
wrapper.app.parameter.5=-in
wrapper.app.parameter.6=TestInstance
the -fn indicates the file name of the service.
the -cn indicates the class name of the service being launched
the -in indicates the instance name of the service
if you have any other parameters needed for your service you can continue to pass them in (just increment the number after the parameter) and they should be passed through to the ruby service.
In DemoService folder there is a demo service that you can look at to see if you have set your service up correctly. Get the demo service, and copy all the contents of the os specific sub-folder to the main folder. So for example if you are at the directory where the wrapper.conf file is do the following (if you are on 32 bit windows)
That will copy the necessary bits.
Next up you can run the demo service in console mode:
DemoService.bat
or install it as a windows service:
InstallDemoService-NT.bat