1

I use the following systemd script for GlassFish 4 on CentOS 7:

[Unit]
Description = GlassFish Server v4.1
After = syslog.target network.target

[Service]
User=glassfish
ExecStart = /usr/bin/java -jar /home/glassfish/glassfish4/glassfish/lib/client/appserver-cli.jar start-domain
ExecStop = /usr/bin/java -jar /home/glassfish/glassfish4/glassfish/lib/client/appserver-cli.jar stop-domain
ExecReload = /usr/bin/java -jar /home/glassfish/glassfish4/glassfish/lib/client/appserver-cli.jar restart-domain
Type = forking

[Install]
WantedBy = multi-user.target

The issue that when execute command "asadmin restart-domain" via web application itself or via NetBeans IDE, or via GlassFish Web admin page => Server => Restart - all processes of GlassFish got halted thus no one able to relaunch the GlassFish again.

In CentOS 6 with original GlassFish script (SysV) - everything works fine.

Any ideas how to fix that?

Edit 1:

1) status of the process after failed restart

# systemctl status glassfish
● glassfish.service - GlassFish Server v4.1.2
    Loaded: loaded (/etc/systemd/system/glassfish.service; enabled; vendor preset: disabled)
    Active: inactive (dead) since Thu 2017-05-25 02:25:46 CDT; 11s ago
  Process: 13465 ExecStop=/usr/bin/java -jar /local/glassfish4/glassfish/lib/client/appserver-cli.jar stop-domain (code=exited, status=0/SUCCESS)
  Process: 13338 ExecStart=/usr/bin/java -jar /local/glassfish4/glassfish/lib/client/appserver-cli.jar start-domain (code=exited, status=0/SUCCESS)
 Main PID: 13351 (code=exited, status=0/SUCCESS)

May 25 02:25:24 dev3.local systemd[1]: Starting GlassFish Server v4.1.2...
May 25 02:25:28 dev3.local java[13338]: Waiting for domain1 to start ....
May 25 02:25:28 dev3.local java[13338]: Successfully started the domain : domain1
May 25 02:25:28 dev3.local java[13338]: domain  Location: /local/glassfish4/glassfish/domains/domain1
May 25 02:25:28 dev3.local java[13338]: Log File: /local/glassfish4/glassfish/domains/domain1/logs/server.log
May 25 02:25:28 dev3.local java[13338]: Admin Port: 4848
May 25 02:25:28 dev3.local java[13338]: Command start-domain executed successfully.
May 25 02:25:29 dev3.local systemd[1]: Started GlassFish Server v4.1.2.
May 25 02:25:46 dev3.local java[13465]: CLI306: Warning - The server located at /local/glassfish4/glassfish/domains/domain1 is not running.
May 25 02:25:46 dev3.local java[13465]: Command stop-domain executed successfully.

2) status of the process after failed restart (having RestartForceExitStatus=SIGUSR1 in systemd config file)

#systemctl status glassfish
● glassfish.service - GlassFish Server v4.1.2
    Loaded: loaded (/etc/systemd/system/glassfish.service; enabled; vendor preset: disabled)
    Active: failed (Result: exit-code) since Thu 2017-05-25 02:15:16 CDT; 15s ago
  Process: 12994 ExecStop=/usr/bin/java -jar /local/glassfish4/glassfish/lib/client/appserver-cli.jar stop-domain (code=exited, status=0/SUCCESS)
  Process: 12859 ExecStart=/usr/bin/java -jar /local/glassfish4/glassfish/lib/client/appserver-cli.jar start-domain (code=exited, status=0/SUCCESS)
 Main PID: 12872 (code=exited, status=12)

May 25 02:13:36 dev3.local java[12859]: domain  Location: /local/glassfish4/glassfish/domains/domain1
May 25 02:13:36 dev3.local java[12859]: Log File: /local/glassfish4/glassfish/domains/domain1/logs/server.log
May 25 02:13:36 dev3.local java[12859]: Admin Port: 4848
May 25 02:13:36 dev3.local java[12859]: Command start-domain executed successfully.
May 25 02:13:37 dev3.local systemd[1]: Started GlassFish Server v4.1.2.
May 25 02:15:15 dev3.local systemd[1]: glassfish.service: main process exited, code=exited, status=12/n/a
May 25 02:15:16 dev3.local java[12994]: CLI306: Warning - The server located at /local/glassfish4/glassfish/domains/domain1 is not running.
May 25 02:15:16 dev3.local java[12994]: Command stop-domain executed successfully.
May 25 02:15:16 dev3.local systemd[1]: Unit glassfish.service entered failed state.
May 25 02:15:16 dev3.local systemd[1]: glassfish.service failed.
AndrewG10i
  • 151
  • 2
  • 7
  • Found the similar issue here (with no solution): https://stackoverflow.com/questions/38609584/glassfish-fails-to-restart-from-web-portail-but-works-with-asadmin-command – AndrewG10i May 23 '17 at 03:11

2 Answers2

1

need to add to the section [Service] Restart=on-failure

enchaslo
  • 11
  • 1
0

I suspect what it does is it sends a SIGUSR1 signal to the glassfish process, which then by defaults to exiting. I'd try by adding RestartForceExitStatus=SIGUSR1 to the service and see if that helps.

Tollef Fog Heen
  • 712
  • 3
  • 10
  • Hi Tollef, thank you for the advice, unfortunately didn't help... I have added daemon status output after failed restart with and without suggested param. Any other suggestions are highly appreciated! ) – AndrewG10i May 25 '17 at 07:32
  • Does using `RestartForceExitStatus=12` (from the output) work better? Does it always exit with 12? – Tollef Fog Heen May 27 '17 at 19:27
  • With status 12 it exits only when param `RestartForceExitStatus=SIGUSR1` is present in the glassfish systemd conf file. Without `RestartForceExitStatus=SIGUSR1` it exits with code 0. I have added `RestartForceExitStatus=12` - looks like it helps only once: you can do restart of glassfish one time, on the second try - it exits with code 0 again and doesn't start again. – AndrewG10i May 28 '17 at 06:39