jenkins the definitive guide

(Jeff_L) #1
In this case, Jenkins will be accessible on http://localhost:8080/hudson.

This option is often used when integrating a stand-alone instance of Jenkins with Apache.

--daemon
If you are running Jenkins on a Unix machine, you can use this option to start Jenkins as a
background task, running as a unix daemon.

--logfile
By default, Jenkins writes its logfile into the current directory. However, on a server, you often
need to write your log files into a predetermined directory. You can use this option to redirect
your messages to some other file:
$ java -jar jenkins.war --logfile=/var/log/jenkins.log

Stopping Jenkins using Ctrl-C is a little brutal, of course—in practice, you would set up a script to start
and stop your server automatically.


If you are running Jenkins using the embedded Winstone application server, you can also restart and
shutdown Jenkins elegantly by calling the Winstone server directly. To do this, you need to specify the
controlPort option when you start Jenkins, as shown here:


$ java -jar jenkins.war --controlPort=8001

A slightly more complete example in a Unix environment might look like this:


$ nohup java -jar jenkins.war --controlPort=8001 > /var/log/jenkins.log 2>&1 &

The key here is the controlPort option. This option gives you the means of stopping or restarting
Jenkins directly via the Winstone tools. The only problem is that you need a matching version of the
Winstone JAR file. Fortunately, one comes bundled with your Jenkins installation, so you don’t have
to look far.


To restart the server, you can run the following command:


$ java -cp $JENKINS_HOME/war/winstone.jar winstone.tools.WinstoneControl reload: \
--host=localhost --port=8001

And to shut it down completely, you can use the following:


$ java -cp $JENKINS_HOME/war/winstone.jar winstone.tools.WinstoneControl shutdown \
--host=localhost --port=8001

Another way to shut down Jenkins cleanly is to invoke the special “/exit” URL, as shown here:


$ wget http://localhost:8080/exit
Free download pdf