Search code examples
dockersupervisordopendj

supervisor manages a process which is started up with a shell script


I'm using supervisord to run multi-service in a container. I want a ldap service for my web application. So I installed and started opendj with the follow info,

Dockerfile

RUN dpkg -i $APP_HOME/packages/opendj_3.0.0-1_all.deb && \
    /opt/opendj/setup \
          --cli \
          --backendType je \
          --baseDN dc=test,dc=net \
          --ldapPort 389 \
          --adminConnectorPort 4444 \
          --rootUserDN cn=Directory\ Manager \
          --rootUserPassword 123456 \
          --no-prompt \
          --noPropertiesFile \
          --acceptLicense \
          --doNotStart

supervisord.conf

[program:ldap]
command=/opt/opendj/bin/start-ds
priority=1

When running my customized imgae, I got the following exiting message for ldap.

2020-05-25 06:46:03,486 INFO exited: ldap (exit status 0; expected)

Logging into the container to get all process status info with supervisorctl status all and ps -aux respectively.

$supervisorctl status all
ldap                             EXITED    May 25 06:46 AM
$ps -aux
root        97  3.4  5.9 3489048 240248 pts/0  Sl   06:15   0:08 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -server -Dorg.opends.server.scriptName=start-ds org.opends.server.core.DirectoryServer --configClass org.opends.server.extensions.ConfigFileHandler

I found the ldap program starting up with start-ds shell script, that is, that start-ds shell process exited, but the ldap server which isn't controlled by supervisor is running. If stopping supervisor subprocesses, the ldap server can't be stopped gracefully.

So my question is how to configure to make the supervisor to control the ldap server process which is started up by start-ds.


Solution

  • Reference Doc says:

    Options

    The start-ds command takes the following options:

    -N | --nodetach
    Do not detach from the terminal and continue running in the foreground. This option cannot be used with the -t, --timeout option.

    Default: false

    The statement in start-ds.sh file is:

    exec "${OPENDJ_JAVA_BIN}" ${OPENDJ_JAVA_ARGS} ${SCRIPT_NAME_ARG} \
      org.opends.server.core.DirectoryServer \
      --configClass org.opends.server.extensions.ConfigFileHandler \
      --configFile "${CONFIG_FILE}" "${@}"
    

    start-ds script will append this option when run /opt/opendj/bin/start-ds -N

    /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -server -Dorg.opends.server.scriptName=start-ds org.opends.server.core.DirectoryServer --configClass org.opends.server.extensions.ConfigFileHandler --configFile /opt/opendj/config/config.ldif -N