Adding Codebeamer service (auto startup)
Typically, when linux is booting, the Codebeamer service should start automatically. The steps to configure this with systemd service is:
Create a Codebeamer user for running Codebeamer instance.
Install Codebeamer: in our example Codebeamer is installed to /home/Codebeamer/CB directory
Create a new file as /etc/systemd/system/Codebeamer.service with this content:


[Unit]

Description=codebeamer service

After=network.target iptables.service firewalld.service firewalld.service httpd.service



[Service]

Type=forking

User=codebeamer

Environment=CB_HOME=/home/codebeamer/CB

ExecStart=/home/codebeamer/CB/bin/startup

ExecStop=/home/codebeamer/CB/bin/stop





[Install]

WantedBy=multi-user.target

If necessary, modify the CB_HOME and User variables in the Service section the script. Remember to save it.
Now to enable the service startup at boot, execute this command:


sudo systemctl enable codebeamer.service

Codebeamer can be stopped by the command below:


sudo systemctl stop codebeamer.service

Codebeamer can be started by this command:


sudo systemctl start codebeamer.service

The status of the service can be queried by this command:


sudo systemctl status codebeamer.service

This will print out something like:


codebeamer.service - codebeamer service

Loaded: loaded (/etc/systemd/system/codebeamer.service; enabled; vendor preset: enabled)

Active: active (running) since Thu 2019-06-06 13:02:41 CEST; 10min ago

Process: 2658 ExecStop=/home/codebeamer/CB/bin/stop (code=exited, status=0/SUCCESS)

Process: 2737 ExecStart=/home/codebeamer/CB/bin/startup (code=exited, status=0/SUCCESS)

Main PID: 2774 (java)

Tasks: 72 (limit: 4915)

CGroup: /system.slice/codebeamer.service

∟2774 java -server -classpath /home/codebhttps://en.wikipedia.org/wiki/Systemdeamer/CB/tomcat/bin/commons-daemon.jar:/home/codebeamer/CB/



Jun 06 13:02:36 ip-172-31-14-69 startup[2737]: INFO: Starting service [Catalina]

Jun 06 13:02:36 ip-172-31-14-69 startup[2737]: Jun 06, 2019 1:02:36 PM org.apache.catalina.core.StandardEngine s

Jun 06 13:02:36 ip-172-31-14-69 startup[2737]: INFO: Starting Servlet Engine: Apache Tomcat/8.5.37

Jun 06 13:02:36 ip-172-31-14-69 startup[2737]: Jun 06, 2019 1:02:36 PM org.apache.catalina.startup.HostConfig de

Jun 06 13:02:36 ip-172-31-14-69 startup[2737]: INFO: Deploying web application directory [/home/codebeamer/CB-9.

Jun 06 13:02:37 ip-172-31-14-69 startup[2737]: Jun 06, 2019 1:02:37 PM org.apache.jasper.servlet.TldScanner scan

Jun 06 13:02:37 ip-172-31-14-69 startup[2737]: INFO: At least one JAR was scanned for TLDs yet contained no TLDs

Jun 06 13:02:37 ip-172-31-14-69 startup[2737]: Jun 06, 2019 1:02:37 PM org.apache.catalina.core.ApplicationConte

Jun 06 13:02:37 ip-172-31-14-69 startup[2737]: INFO: Initializing Spring root WebApplicationContext

Jun 06 13:02:41 ip-172-31-14-69 systemd[1]: Started codebeamer service.



Legacy: using init.d for startup
For older systems you can also use init.d service to start up Codebeamer with the system. This is not recommended though as systemd is replaced init.d !
Steps:
Create a new file in /etc/init.d/Codebeamer with this content:
#!/bin/bash

#

### BEGIN INIT INFO

# Provides: codebeamer

# Required-Start: $remote_fs $syslog $network

# Required-Stop: $remote_fs $syslog $network

# Default-Start: 2 3 4 5

# Default-Stop: 0 1 6

# Short-Description: Start and stop codebeamer

# Description: Controls the codebeamer Server

### END INIT INFO



CB_HOME="/home/codebeamer/CB"

CB_OWNR="codebeamer"



case "$1" in

start)

# startup

echo -n "Starting codebeamer: "

su - $CB_OWNR -c "cd $CB_HOME/bin && $CB_HOME/bin/startup"

echo "OK"

;;

stop)

# shutdown

echo -n "Shutdown codebeamer: "

su - $CB_OWNR -c "cd $CB_HOME/bin && $CB_HOME/bin/stop"

echo "OK"

;;

reload|restart)

$0 stop

$0 start

;;

*)

echo "Usage: $0 start|stop|restart|reload"

exit 1

esac

exit 0

If necessary, modify the CB_HOME and CB_OWNR variables at the start of the script. Remember to save it.
Now to activate the service, execute these commands:
$ sudo chmod +x /etc/init.d/codebeamer

$ sudo update-rc.d codebeamer defaults

It must be ensured that Codebeamer is not running before the service can be started or stopped.
Codebeamer can be stopped by the command below:
$ /home/codebeamer/CB/bin/stop
After this, the Codebeamer service is set up, and can be started/stopped using the service commands:
$ sudo service codebeamer start

$ sudo service codebeamer stop

Was this helpful?