Launching OpenMRS automatically as a service
This page is outdated and no longer receives updates!
These are the steps to follow for making the OpenMRS launch automatically. We want our server to start automatically, so it starts after booting the pc and when is network available.
Â
Sript for launching the openmrs server:
#!/bin/bash cd /home/pere/Documents/referenceapplication-standalone-2.7.0/Â
java -jar openmrs-standalone.jar -commandline -tomcatport 8081
Â
Number of port used by tomcat is arbitrary
Â
We have to save it in:/usr/local/bin/
Â
Now, create a file called:Â /lib/system/system/OpenMRS.service
Â
It has to contain:
[Unit]
Description=Launch OpenMRS server service
After=network.target
StartLimitIntervalSec=0
[Service] Type=simple
RestartSec=1
User=pere
ExecStart=/usr/local/bin/launchServer.sh
[Install] WantedBy=multi-user.target
Â
Where User=
 field contains the user’s session name and ExecStart =
 the path to run the script.
Â
Â
Â
Now, start the service:
Â
$ sudo systemctl start OpenMRS
Â
And start on boot:
Â
$ sudo systemctl enable OpenMRS
Â
Â
For checking the status of the service:
Â
$ systemctl status OpenMRS.service
Â