systemd is backwards compatible with Linux initialization scripts as detailed in: How To Configure a Linux Service to Start Automatically After a Crash or Reboot – Part 1: Practical Examples.
The key thing to be aware of when using systemd is that you must create your own init scripts and enable the services to start automatically. This article describes how you can do this with DS/OpenDJ.
- Generate a DS/OpenDJ init script by running the create-rc-script tool as detailed
in Administration Guide › Managing Server Processes. For example:
$ ./create-rc-script --userName root --outputFile opendj.initYou can view the attached example init script that was generated for OpenDJ 3.5.
- Create a service file and enable that service using the guidelines given in Auto-starting Services with systemd:
- Create a service file; this example demonstrates creating the service file by copying
the VirtualBox® service file:
$ cd /usr/lib/systemd/system $ cp vboxadd.service opendj.serviceYou should ensure Restart=always in this file to enable the service to respawn after a crash. You can view the attached example service file that was created in this way for OpenDJ 3.5.
- Enable the service file:
$ sudo systemctl enable opendj.service
- Reload the daemon:
$ sudo systemctl daemon-reload
- Create a service file; this example demonstrates creating the service file by copying the VirtualBox® service file:
- Stop and restart DS/OpenDJ:
$ ./stop-ds $ ./start-ds
- Verify the service is online as follows:
$ systemctl is-enabled opendj.service enabled $ systemctl status opendj.service opendj.service - ForgeRock OpenDJ 3.5.0 Loaded: loaded (/opt/opendj/bin; enabled) Active: active (exited) since Fri 2017-09-29 14:17:41 GMT; 7min ago Process: 650 ExecStart=/opt/opendj/bin/opendj.init start (code=exited, status=0/SUCCESS) Sep 29 14:17:20 localhost.localdomain su: (to root) root on none Sep 29 14:17:41 opendj.forgerock.com systemd: Started ForgeRock OpenDJ 3.5.0.