Version: 5.4.x

Run the OpenHIM on startup

This how to guide assumes the following

  • You are working on an Ubuntu server
  • The OpenHIM Core is already installed using npm
  • NodeJS is installed

Make sure the OpenHIM Core is not currently running on your machine before proceeding.

systemd#

To help you get the OpenHIM server running on boot we supply a script for systemd.

To setup the service create the following file with your editor of choice (vim in this example) and put in the above content:

sudo vim /lib/systemd/system/openhim-core.service

For the ExecStart field fill in the correct paths to NodeJS and your OpenHIM Core module. To find these directory paths try the following:

which node

This will show you where NodeJS is installed. The OpenHIM npm module will be installed nearby (usually within ../../lib/node_modules/openhim-core in relation to node).

Your ExecStart field should look something like this:

ExecStart=/usr/local/bin/node /usr/local/lib/node_modules/openhim-core/lib/server.js

If you have installed NodeJS using nvm the directory base will be /home/<user>/.nvm/versions/node/<node-version>/ instead of /usr/local/

Once your script is complete reload systemd with the following command:

sudo systemctl daemon-reload

Then, start the service:

sudo systemctl start openhim-core

Next check the service status:

sudo systemctl status openhim-core

You can confirm that the OpenHIM is accessible by navigating to https://localhost:8080/heartbeat on a browser. The browser will give you a security warning as SSL has not been setup yet. Accept the risk and the browser should return the OpenHIM uptime.

To diagnose any problems you can view the OpenHIM logs from the service with the following:

journalctl -u openhim-core.service -b

To configure the OpenHIM to run on server startup type the following:

sudo systemctl enable openhim-core