0

I came across a problem with visualising the status of an AIX service. So first I create subsystem pointing to a shell script which I will use for running.

mkssys -s testService -p /etc/rc.d/init.d/runScriptWithCatalina.sh -u 0

Now if I start the service as startsrc -s testService -a "start", it shows that the subsystem has been started.

0513-059 The testService Subsystem has been started. Subsystem PID is 9502912.

and the service is working indeed. However, when I check the subsystem status with lssrc -a, it shows that it is inoperative. I figured out that the reason behind this is when the subsystem is started, it calls the runScriptWithCatalina.sh which calls the catalina.sh script to start and the catalina.sh forks and creates new process and the subsystem cannot detect it, that is why it shows it is inoperative. Here is the catalina script - https://github.com/magro/msm-sample-webapp/blob/master/runtime/apache-tomcat-6.0.32/bin/catalina.sh. The tomcad.pid file contains pid different from the subsystem PID shown 9502912.

Is there a solution or workaround for this, or another approach?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Gordon
  • 21

2 Answers2

1

The System Resource Controller is showing the correct status, so far as it's concerned -- the PID that it started has now exited. My best suggestion for getting SRC to indicate your expected status would be to ensure that the chain of scripts exec's each subsequent one, so that the tail-end java process occupies the same PID that the initial script did.

Stripped-down example:

File: runScriptWithCatalina.sh

# ...
exec /path/to/catalina.sh

File: /path/to/catalina.sh

# ...
exec java ...
Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
1

catalina.sh is in the systemd House of Horror, and the things that apply to systemd today have applied to the IBM System Resource Controller for 30 years. I actually quote an IBM Redbook on one of my Frequently Given Answers, where it was telling people the correct way to write dæmons to run under the SRC, that applies just as much to other systems, back in 1995.

Using catalina.sh's bodge Poor Man's Dæmon Supervisor and Bad Logger is not the right way.

Wrapping catalina.sh in another script is most definitely not the right way. I said not to use that rc script at https://unix.stackexchange.com/a/563486/5132 .

The best approach is just to get rid of catalina.sh. Strip out all of the stuff that is a Poor Man's Dæmon Supervisor and Bad Logger, or that is completely irrelevant to AIX, and you'll find that it does very little, setting some environment variables and then running the java command. That can be done directly, and many people do it directly.

The somewhat inferior approach to that is to use the run verb for catalina.sh.

Further reading

JdeBP
  • 68,745