
Background
Integrating our own custom services with Fast ESP’s Node Controller provides us with several benefits:
- Administrators without in-depth ESP knowledge can easily control services (e.g. start, stop, configure parameters)
- Services can be started at boot time with the rest of ESP
espdeploy
can be used to install our services in a multi-node cluster
The components required for this system are:
- The ESP Node Controller (with config file
NodeConf.xml
) - The 3rd-party service (like a CherryPy server, log parser, etc.)
- A wrapper script (see below)
Steps for Integration
- Define the service you would like to integrate. It can be any script or binary that can be executed on the system. For example, the service might be a python script that takes command-line arguments and continues running itself (as is the case with a webserver).
- Create the wrapper script that sets up the proper environment and runs/stops the service properly. The wrapper script should be put in the $FASTSEARCH/bin directory (with executable permissions). Additionally, the wrapper script should pass $@ to your actual script so any/all arguments defined in $FASTSEARCH/etc/NodeConf.xml will be passed along properly from the Node Controller to your service. The following is an example of a wrapper script:
#!/bin/sh # export the proper python path export PYTHONPATH=":/path/to/python" # run the script (backgrounded) python $FASTSEARCH/lib/python2.6/yourmodule/yourservice.py $@ & # determine the process id of the python script SCRIPT_PID="$!" # upon receiving a SIGTERM, forward it to the process trap "kill -TERM $SCRIPT_PID" SIGTERM # wait for SIGTERM from nctrl wait
- Define the service in $FASTSEARCH/etc/NodeConf.xml
Add the following to the end of the <startorder> tag:<proc>servicename</proc>
Add the following to the end of the <node> tag, customizing as appropriate:
<!-- My Custom Service --> <process name="servicename" description="My Custom Service"> <start> <executable>binaryname</executable> <parameters>-p 16940 -v</parameters> <port base="4004"/> </start> <outfile>servicename.scrap</outfile> </process>
- Reload the Node Controller configuration with the following:
nctrl reloadcfg
And that’s it! Now you should be able to start, stop, configure, and deploy your services using Fast ESP tools. Enjoy!
Thankyou for visiting http://www.fastesphelp.com