Step 1 - Install and Configure
For production usage, we strongly recommend to set up the CLM server as a service or daemon. This will ensure that any operating system reboots will include starting up the CLM server.
A dedicated user for running a service is a well known best practice. This users should have reduced access rights as compared to the root user. Configuration of this user will depend on the operating system and security system used.
Once the user is configured, you need to ensure that full access rights to the CLM server installation directory are granted. An example command to achieve this for a service user with the username clmserver is:
chown -Rv clmserver /opt/sonatype-clm-server
If you have configured the sonatypeWork
parameter in config.yml
to
point to a different directory, you have to adjust the access rights
for it as well.
The principal command for starting the CLM server can be used in a
simple startup script as displayed in
Startup Script. The javaopts
variable should be
adjusted to suit the hardware used.
#! /bin/sh cd /opt/sonatype-clm-server javaopts="-Xmx1024m -XX:MaxPermSize=128m" java $javaopts -jar sonatype-clm-server-1.10.2.jar server config.yml
A running server can be stopped with a simple shutdown script in Shutdown script.
#!/bin/sh pid=`ps aux | grep sonatype-clm-server | grep -v grep | awk '{print $2}'` kill $pid
Typically these approaches are combined to a service script similar to
the script listed in Simplistic Service Script for Unix Systems. Saving this
script as e.g. sonatype-clm-server
allows you to start the server
with its log running to the current shell with
./sonatype-clm-server console
Starting as a background process can be initiated with:
./sonatype-clm-server start
and a running background server can be stopped with:
./sonatype-clm-server stop
This example script can be improved to be more robust against repeat invocations, long running stops and potentially work better across different Unix flavours, but shows the principal functionality. A similar script can be used for Windows.
Simplistic Service Script for Unix Systems.
#!/bin/sh SONATYPE_CLM_SERVER_HOME=/opt/tools/sonatype-clm-server VERSION=1.10.2 JAVA_OPTIONS="-Xmx1024m -XX:MaxPermSize=128m" # The user ID which should be used to run the CLM server # # IMPORTANT - Make sure that the user has the required privileges to write into the CLM work directory. RUN_AS_USER=clm do_start() { cd $SONATYPE_CLM_SERVER_HOME su -m $RUN_AS_USER -c "java -jar $JAVA_OPTIONS sonatype-clm-server-$VERSION.jar server config.yml > /dev/null 2>&1 &" echo "Started Sonatype CLM Server" } do_console() { cd $SONATYPE_CLM_SERVER_HOME java -jar $JAVA_OPTIONS sonatype-clm-server-$VERSION.jar server config.yml } do_stop() { pid=`ps aux | grep sonatype-clm-server | grep -v grep | awk '{print $2}'` kill $pid echo "Killed Sonatype CLM Server - PID $pid" } do_usage() { echo "Usage: clm [console|start|stop]" } case $1 in console) do_console ;; start) do_start ;; stop) do_stop ;; *) do_usage ;; esac
Setting up this script as a startup script will vary between operating systems and distributions depending on the init system used. Generally the script would be copied to a dedicated startup directory and assigned with run-levels and other characteristics for the start up. As an example on a Debian based systems the following commands could be used:
sudo su cp sonatype-clm-server /etc/init.d/ cd /etc/init.d update-rc.d sonatype-clm-server defaults service sonatype-clm-server start
Depending on the requirements from your system administrator the scripts will have to be modified to fit into your environment and exact deployment scenario.