Background
A Fredhopper deployment requires a running Deployment Agent. This agent is used for starting, monitoring, and stopping Fredhopper applications. The agent should be started at system boot time, and stopped only when the system is shut down or an upgrade is performed.
The following steps describe how do do that using a Linux init script for the SysV init.
|
Upstart Newer Linux versions have replaced the SysV init with upstart (http://upstart.ubuntu.com/). Usually a compatibility package provides support for using SysV init scripts, but this may have to be installed manually. Please consult the documentation of the distribution to learn about the system startup process if you're unsure. |
Steps
Step 1: Prepare the script
The Fredhopper deployment package comes with a helper script bin/fredhopper that provides all the needed functions. This script must be executed from the Fredhopper deployment package installation directory, and cannot be used directly as an init script.
| bin/fredhopper argument | Behavior |
|---|---|
| start | Starts the deployment agent, and exits with '0' when the agent is running. If the agent cannot be started the exit value will be '1'. |
| stop | Stops the deployment agent if it is currently running, and exits with '0'. |
| status | Checks whether the agent is running, and exits with '0' if it is running, or '1' if the agent is not running |
A minimal SysV init script /etc/init.d/fredhopper that uses bin/fredhopper would be:
#!/bin/sh ### BEGIN INIT INFO # Provides: fredhopper # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Description: Start Fredhopper deployment agent ### END INIT INFO # Change this to the name of the fredhopper user USER=fredhopper # Change this to point to the fredhopper deployment package installation directory FREDHOPPER_HOME=/home/fredhopper su -c "cd ${FREDHOPPER_HOME}; bin/fredhopper $1" ${USER}
- Create /etc/init.d/fredhopper using the example. Adjust the USER and FREDHOPPER_HOME definitions to match your environment.
- Make the script executable:
# chmod 755 /etc/init.d/fredhopper
Step 2: Test
Before enabling the script to run on boot time verify that all functions work. For the verification you should run the /etc/init.d/fredhopper script as the 'root' user, using the minimal environment to closely simulate the processes at boot.
- Disable any running deployment agent by executing bin/fredhopper stop as the fredhopper user from the fredhopper directory.
- Become root
$ su - root
- Test the init script using the following table
Command Expected Behavior /etc/init.d/fredhopper start && echo PASSED Should block until the agent is available, and then print 20110211-170844 INFO deployment-agent is up PASSED
/etc/init.d/fredhopper status && echo PASSED Should print 20110211-173804 INFO deployment-agent is up on host: host.example.com PASSED
/etc/init.d/fredhopper stop && echo PASSED Should print PASSED
/etc/init.d/fredhopper status || echo PASSED Should print 20110211-173916 ERROR deployment-agent is not running on host: host.example.com PASSED
Step 3: Enable the script
You can enable the script to run at boot time using
# /sbin/chkconfig --add fredhopper
You can verify that the script is enabled using
# /sbin/chkconfig --list fredhopper
You can disable the script to run at boot time using
# /sbin/chkconfig --del fredhopper
Limitations
It is possible to automatically start Fredhopper instances at machine boot time using a similar approach. But this has drawbacks:
- an unexpected machine reboot may have corrupted data and/or configuration, and starting instances automatically will lead to hard-to-find issues on the site.
- more advanced init systems like upstart may try to impose a different life-cycle on the services controlled by the system. This will interfere with the Fredhopper deployment scripts and jobs.
Comments
0 comments
Please sign in to leave a comment.