How To

How do I configure DS/OpenDJ (All versions) to be stopped and started as a service using systemd and systemctl?

Last updated Jul 9, 2018

The purpose of this article is to provide assistance with configuring DS/OpenDJ to be stopped and started as a service using systemd and systemctl if you are using a Linux® system. This method uses init scripts created with create-rc script.


Overview

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.

Configuring DS/OpenDJ

  1. 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.init
    
    You can view the attached example init script that was generated for OpenDJ 3.5.
  2. Create a service file and enable that service using the guidelines given in Auto-starting Services with systemd
    1. 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.service
      You 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.
    2. Enable the service file:
      $ sudo systemctl enable opendj.service
      
    3. Reload the daemon:
      $ sudo systemctl daemon-reload	
  3. Stop and restart DS/OpenDJ:
    $ ./stop-ds
    $ ./start-ds
  4. 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[665]: (to root) root on none
    Sep 29 14:17:41 opendj.forgerock.com systemd[1]: Started ForgeRock OpenDJ 3.5.0.
    

See Also

Administration Guide › Managing Server Processes

How To Configure a Linux Service to Start Automatically After a Crash or Reboot – Part 1: Practical Examples

Related Training

N/A

Related Issue Tracker IDs

OPENDJ-3810 (Add Linux systemd support for OPENDJ startup)



Copyright and TrademarksCopyright © 2018 ForgeRock, all rights reserved.

Recommended Books

Loading...