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 You can enable this service to run on startup and manage the Tomcat service using |
Configure AM as a service
-
Create a service file using your preferred text editor:
$ sudo vim /etc/systemd/system/am.service
-
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
-
Reload the daemon:
$ sudo systemctl daemon-reload
-
Make the new service launch on startup:
$ sudo systemctl enable am.service
-
Check the service is enabled:
$ systemctl is-enabled am.service
This command returns
enabled
ordisabled
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.