2

Unable to fork initd scripts on Centos 7. I have installed JBOSS EAP7 which comes with inbuilt initd scripts to start the service. I start/stop/restart the services like the following which works fine. However, when I fork the same initd scripts via systemd it doesn't work. Any help would be appreciated.

# /opt/jboss/bin/init.d/jboss-eap-rhel.sh start
Starting jboss-eap: /root
                                                           [  OK  ]
# /opt/jboss/bin/init.d/jboss-eap-rhel.sh status
jboss-eap is running (pid 3024)

# /opt/jboss/bin/init.d/jboss-eap-rhel.sh stop
Stopping jboss-eap:                                        [  OK  ]

# /opt/jboss/bin/init.d/jboss-eap-rhel.sh status
jboss-eap is not running

# /opt/jboss/bin/init.d/jboss-eap-rhel.sh start
Starting jboss-eap: /root
                                                           [  OK  ]
# /opt/jboss/bin/init.d/jboss-eap-rhel.sh status
jboss-eap is running (pid 3314)

Forking the same initd scripts via systemd, gives an error.

# cat /etc/systemd/system/jbosseap7.service
[Unit]
Description=JBoss EAP7
After=syslog.target
After=network.target

[Service]
Type=forking
ExecStart=/opt/jboss/bin/init.d/jboss-eap-rhel.sh start
ExecStop=/opt/jboss/bin/init.d/jboss-eap-rhel.sh stop
ExecReload=/opt/jboss/bin/init.d/jboss-eap-rhel.sh restart
PIDFile=/var/run/jboss-eap/jboss-eap-standalone.pid

[Install]
WantedBy=multi-user.target


# time systemctl start jbosseap7
Job for jbosseap7.service failed because a timeout was exceeded. See "systemctl status jbosseap7.service" and "journalctl -xe" for details.

real    **1m27.330s**
user    0m0.008s
sys     0m0.003s

# time systemctl status jbosseap7
● jbosseap7.service - JBoss EAP7
   Loaded: loaded (/etc/systemd/system/jbosseap7.service; enabled; vendor preset: disabled)
   Active: failed (Result: timeout) since Mon 2018-06-11 07:04:29 EDT; 15s ago

Jun 11 06:58:22 node01.local.com systemd[1]: Starting JBoss EAP7...
Jun 11 06:58:22 node01.local.com runuser[4071]: pam_unix(runuser:session): session opened for user jboss by (uid=0)
Jun 11 06:58:22 node01.local.com jboss-eap-rhel.sh[4060]: Starting jboss-eap: /
Jun 11 06:58:39 node01.local.com jboss-eap-rhel.sh[4060]: [  OK  ]
Jun 11 06:58:39 node01.local.com systemd[1]: PID file /var/run/jboss-eap/jboss-eap-standalone.pid not readable (yet?) after start.
Jun 11 07:04:28 node01.local.com systemd[1]: jbosseap7.service start operation timed out. Terminating.
Jun 11 07:04:29 node01.local.com systemd[1]: Failed to start JBoss EAP7.
Jun 11 07:04:29 node01.local.com systemd[1]: Unit jbosseap7.service entered failed state.
Jun 11 07:04:29 node01.local.com systemd[1]: jbosseap7.service failed.

real    0m0.045s
user    0m0.004s
sys     0m0.000s

Note: I have even tried specifying the Timeout limit under [SERVICE] unit, but that still doesn't work. Without specifying the time limit it still takes a long time (1 minute & 27 seconds). What could be wrong here?

Additional Comments:

Sometimes it starts and sometimes it doesn't start. How can we nail down the failed one?

# systemctl start jbosseap7
# systemctl status jbosseap7
● jbosseap7.service - JBoss EAP7
   Loaded: loaded (/etc/systemd/system/jbosseap7.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Mon 2018-06-11 07:32:47 EDT; 7s ago
  Process: 2913 ExecStop=/etc/init.d/jboss-eap-rhel.sh stop (code=exited, status=0/SUCCESS)
  Process: 2771 ExecStart=/etc/init.d/jboss-eap-rhel.sh start (code=exited, status=0/SUCCESS)
 Main PID: 2537 (code=exited, status=0/SUCCESS)

Jun 11 07:32:15 node01.local.com systemd[1]: Starting JBoss EAP7...
Jun 11 07:32:15 node01.local.com runuser[2782]: pam_unix(runuser:session): session opened for user jboss by (uid=0)
Jun 11 07:32:15 node01.local.com jboss-eap-rhel.sh[2771]: Starting jboss-eap: /
Jun 11 07:32:46 node01.local.com jboss-eap-rhel.sh[2771]: jboss-eap started with errors, please see server log for details
Jun 11 07:32:46 node01.local.com jboss-eap-rhel.sh[2771]: [  OK  ]
Jun 11 07:32:47 node01.local.com jboss-eap-rhel.sh[2913]: Stopping jboss-eap: [  OK  ]
Jun 11 07:32:47 node01.local.com systemd[1]: Started JBoss EAP7.

# ps -ef | grep jboss
root      2924  2222  0 07:33 pts/0    00:00:00 grep --color=auto jboss

# systemctl start jbosseap7

# systemctl status jbosseap7
● jbosseap7.service - JBoss EAP7
   Loaded: loaded (/etc/systemd/system/jbosseap7.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2018-06-11 07:33:35 EDT; 3s ago
  Process: 2913 ExecStop=/etc/init.d/jboss-eap-rhel.sh stop (code=exited, status=0/SUCCESS)
  Process: 2930 ExecStart=/etc/init.d/jboss-eap-rhel.sh start (code=exited, status=0/SUCCESS)
 Main PID: 2943 (standalone.sh)
   CGroup: /system.slice/jbosseap7.service
           ├─2943 /bin/sh /opt/jboss/bin/standalone.sh -c standalone.xml
           └─3012 java -D[Standalone] -server -verbose:gc -Xloggc:/opt/jboss/standalone/log/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:Nu...

Jun 11 07:33:19 node01.local.com systemd[1]: Starting JBoss EAP7...
Jun 11 07:33:19 node01.local.com runuser[2941]: pam_unix(runuser:session): session opened for user jboss by (uid=0)
Jun 11 07:33:19 node01.local.com jboss-eap-rhel.sh[2930]: Starting jboss-eap: /
Jun 11 07:33:35 node01.local.com jboss-eap-rhel.sh[2930]: [  OK  ]
Jun 11 07:33:35 node01.local.com systemd[1]: Started JBoss EAP7.

PS Results:

# ps -aux|grep jboss
jboss     4559  0.0  0.0 113120  1540 ?        S    07:58   0:00 /bin/sh /opt/jboss/bin/standalone.sh -c standalone.xml
jboss     4628 49.4 33.9 3077608 640432 ?      Sl   07:58   0:15 java -D[Standalone] -server -verbose:gc -Xloggc:/opt/jboss/standalone/log/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -XX:-TraceClassUnloading -Xms1303m -Xmx1303m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Dorg.jboss.boot.log.file=/opt/jboss/standalone/log/server.log -Dlogging.configuration=file:/opt/jboss/standalone/configuration/logging.properties -jar /opt/jboss/jboss-modules.jar -mp /opt/jboss/modules org.jboss.as.standalone -Djboss.home.dir=/opt/jboss -Djboss.server.base.dir=/opt/jboss/standalone -c standalone.xml
root      4754  0.0  0.0 112644   952 pts/0    R+   07:58   0:00 grep --color=auto jboss
Gokulnath Kumar
  • 85
  • 1
  • 2
  • 18

1 Answers1

1

From the logs of systemctl daemon, it is obvious that it is trying to read the pid file of jboss.

Hence, first remove its pid file:

rm /var/run/jboss-eap/jboss-eap-standalone.pid

Now, comment the below line and reload the daemon:

#PIDFile=/var/run/jboss-eap/jboss-eap-standalone.pid
systemctl daemon-reload

Then start jboss service.

systemctl start jbosseap7
erTugRul
  • 516
  • 1
  • 6
  • 16