Hi everybody! I’m working on a project using OpenMRS and a client-server android app. I’m pretty new using OpenMRS, so I’ll try to do my best to explain my issue.
I’m trying to launch automatically the server (Standalone-2.7.0) as a service once the computer is already on and the network is working. I’m using Ubuntu 16.04.1
This is the simple shell script I’m running:
#!/bin/bash
cd /home/pere/Documents/referenceapplication-standalone-2.7.0/
java -jar openmrs-standalone.jar`
And this is the .service file:
[Unit]
Description=Launch OpenMRS server service
After=network.service
StartLimitIntervalSec=0
[Service]
Type=simple
RestartSec=1
User=pere
ExecStart=/usr/local/bin/launchServer.sh
[Install]
WantedBy=multi-user.target
If I check the status of the service once the computer is on I got the following error:
● launchOpenmrs.service - Launch OpenMRS server service
Loaded: loaded (/lib/systemd/system/launchOpenmrs.service; enabled; vendor preset: enabled)
Active: inactive (dead) since ven. 2018-09-07 15:07:40 CEST; 12min ago
Process: 771 ExecStart=/usr/local/bin/launchServer.sh (code=exited, status=0/SUCCESS)
Main PID: 771 (code=exited, status=0/SUCCESS)
sept. 07 15:07:40 nicotris launchServer.sh[771]: at java.awt.Window.<init>(Window.java:536)
sept. 07 15:07:40 nicotris launchServer.sh[771]: at java.awt.Frame.<init>(Frame.java:420)
sept. 07 15:07:40 nicotris launchServer.sh[771]: at java.awt.Frame.<init>(Frame.java:385)
sept. 07 15:07:40 nicotris launchServer.sh[771]: at javax.swing.JFrame.<init>(JFrame.java:189)
sept. 07 15:07:40 nicotris launchServer.sh[771]: at org.openmrs.standalone.MainFrame.<init>(MainFrame.java:68)
sept. 07 15:07:40 nicotris launchServer.sh[771]: at org.openmrs.standalone.ApplicationController.init(ApplicationController.java:227)
sept. 07 15:07:40 nicotris launchServer.sh[771]: at org.openmrs.standalone.ApplicationController.<init>(ApplicationController.java:55)
sept. 07 15:07:40 nicotris launchServer.sh[771]: at org.openmrs.standalone.ApplicationController.main(ApplicationController.java:126)
sept. 07 15:07:40 nicotris launchServer.sh[771]: Exit:1
sept. 07 15:07:40 nicotris launchServer.sh[771]: [MysqldResource] Mysqld not running. No file: /home/pere/Documents/referenceapplication-standalone-2.7.0/database/data/MysqldResource.pid
It seems like is trying to find the file MysqldResource.pid file but it doesn’t finds it. However, if I run the shell, for instance, from the desktop OpenMRS starts normally and working fine.
I have been looking in the forum, but I haven’t found any topic talking about this issue. I would be very appreciated if you could help me.
It finally worked. There were problems with the graphic console. It can not be launched as a service. So I only had to execute the jar file in commandline mode.
I made a quick guide for make run OpenMRS as a service and launch it automatically after boot and after this is network available. It might be useful for somebody!
Here it goes:
Launching OpenMRS automatically as a service
Steps to follow for making the OpenMRS launch automatically. It starts automatically after booting the pc and when is network available.
Script to launch the server:
#!/bin/bash
cd /home/pere/Documents/referenceapplication-standalone-2.7.0/
java -jar openmrs-standalone.jar -commandline
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.
You’re welcome! I think that is the spirit for this kind of projects.
By the wat @dkayiwa, it seems that I do not have access to the wiki page due to my “basic user” status. Could it be possible? If it is not about permissions, I don’t know why I can’t log in the wiki page.