PingAM 7.5.1

Run AM as a service

AM can run as a service on a standard systemd-based Linux distribution. Once you have configured AM as a service, you can stop and start AM using systemd.

These instructions assume you have deployed AM on Apache Tomcat.

A service file (called tomcat) is created if you install Tomcat using a package manager such as yum. You can use this service file instead of creating your own.

You can enable this service to run on startup and manage the Tomcat service using systemctl commands. Replace am.service in these example commands with tomcat.

Configure AM as a service

  1. Create a service file using your preferred text editor:

    $ sudo vim /etc/systemd/system/am.service
  2. Add the following content to this file, update all the values as needed, and save:

    [Unit]
    Description=AM (Apache Tomcat)
    After=network.target
    
    [Service]
    Type=forking
    
    Environment=JAVA_HOME=/path/to/jdk
    Environment=CATALINA_PID=/path/to/tomcat/temp/tomcat.pid
    Environment=CATALINA_HOME=/path/to/tomcat
    Environment=CATALINA_BASE=/path/to/tomcat
    Environment='CATALINA_OPTS=-Xmx2048m -server -XX:+UseParallelGC'
    Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'
    
    ExecStart=/path/to/tomcat/bin/startup.sh
    ExecStop=/path/to/tomcat/bin/shutdown.sh
    
    User=tomcat_user
    Group=tomcat_user
    
    [Install]
    WantedBy=multi-user.target
  3. Reload the daemon:

    $ sudo systemctl daemon-reload
  4. Make the new service launch on startup:

    $ sudo systemctl enable am.service
  5. Check the service is enabled:

    $ systemctl is-enabled am.service

    This command returns enabled or disabled as appropriate.

Use systemctl commands to manage the AM service

Once you’ve configured AM as a service and checked it’s enabled, use systemctl commands to manage the AM service:

  • Start the service:

    $ sudo systemctl start am.service
  • Stop the service:

    $ sudo systemctl stop am.service
  • Restart the service:

    $ sudo systemctl restart am.service
  • Check the service status:

    $ sudo systemctl status am.service

    This command returns the service state (whether the service has started or stopped as expected) and the first few entries of the AM log file.