A Sample Systemd Unit File

Starting in Red Hat Enterprise Linux 7, the systemd init daemon is used, instead of the upstart init daemon. This uses the concept of targets defined in a unit file.

The following is an example of a gridserver.service unit file for the GridServer Manager running on a RedHat 7 Linux system:

[Unit] 
Description=Datasynapse Manager service
After=network.service NetworkManager.service NetworkManager-wait-online.service
 
[Service]
Type=forking
User=root
PIDFile=/opt/datasynapse/manager-data/java.pid
 
Environment=DS_DATA_DIR=/opt/datasynapse/manager-data
Environment=JAVA_HOME=/usr/local/java
WorkingDirectory=/opt/datasynapse/manager
ExecStart=/opt/datasynapse/manager/server.sh start
ExecStop=/opt/datasynapse/manager/server.sh stop
 
[Install]
WantedBy=default.target

After creating the above file and naming it gridserver.service, place it in /etc/systemd/system/. Refer to the Red Hat documentation for a full understanding of your options for the placement of this file.

The above example sets WantedBy=default.target, which creates a "want" dependency for the default.target related to this service. If you are using a different target in your environment, you might want to use that target instead of the default.target above.