If you are using apache plus tomcat to run your website, you are probably also using jkManager as your loadbalancer. jkManager has a small and lightweight web interface where you can see the load of the working nodes, and you can change their states. Wouldn’t it be nice if you could start and stop your workers from the command line?
It is very easy to change the worker states from shell using wget and a small shell script. When administrate you workers through the web interface, you might notice that after you apply the new setting (before being forwarded to the overview page), the location bar of the browser shows a rather long url with a lot of parameters. E.g. if you activate a worker called “node2″ you will see something like this:
As you can see, node2 is mentioned two times, and there is another parameter call wa. The number behind wa correspends to the new state to be set:
- 0: activate
- 1: disable
- 2: stop
So all you need to do if you want to change the worker state from shell is to modify the url shown above by setting your domain, the desired state and replace the occurrences of node2 by your worker name, and then request that url through wget.
If your jkmanager is protected by basic http authentication (.htpasswd) you can set the user name and the password for wget by using
wget --http-user=USER --http-password=PASSWORD ...
Also, wget will actually download the index.html to the current working directory. You can change the location of the downloaded file by using
wget -O /tmp/not-needed.html