Skip to content

Instantly share code, notes, and snippets.

@nkonev
Last active December 14, 2022 18:31
Show Gist options
  • Save nkonev/1110431b45a399f950c3483bf6813135 to your computer and use it in GitHub Desktop.
Save nkonev/1110431b45a399f950c3483bf6813135 to your computer and use it in GitHub Desktop.
systemctl GlassFish start script
[Unit]
Description=GlassFish Server
After=syslog.target network.target
[Service]
Type=forking
ExecStart=/opt/glassfish4/bin/asadmin start-domain domain1
ExecStop=/opt/glassfish4/bin/asadmin stop-domain domain1
TimeoutSec=180
[Install]
WantedBy=multi-user.target
@nkonev
Copy link
Author

nkonev commented May 4, 2017

This is the systemctl start script I use on CentOS 7 to start GlassFish at system boot. Note that these instructions assume GlassFish is installed to /opt/glassfish4 and JAVA_HOME is set to /opt/java. Here are the steps. First, add this to the end of /opt/glassfish4/glassfish/config/asenv.conf:

AS_JAVA="/opt/java"

Next, copy the Gist contents to a new file: /usr/lib/systemd/system/glassfish.service.

Finally, run the commands:

systemctl daemon-reload
systemctl enable glassfish
systemctl start glassfish

If you are able to reboot the server, you might want to reboot to test that GlassFish starts at boot.

You can check GlassFish status anytime with:

systemctl status glassfish

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment