Hi,
I'm not sure if this is the correct list to ask this question, it's about
systemd unit configuration.
We have a 3rd party application that starts and stops via startup and shutdown
scripts which we would like to have start up automatically at linux boot time.
The start script calls other scripts to start two application components and
then the start script exits.
One of the application components also spawns a couple of child processes.
There ends up being two pid files, one for each component, describing the state
of the application.
Below is an iteration of the unit service file for the application:
--------------------------------------------------------------------------------
[Unit]
Description=XXX Application
RequiresMountsFor=/ /opt /tmp
After=network-online.target sshd.service
Requires=sshd.service
[Service]
Type=oneshot
User=xxx
UMask=0764
TimeoutSec=360s
LimitSTACK=infinity
LimitNOFILE=8192
Environment=HOME=/home/xxx
Environment=JAVA_HOME=/opt/xxx/jre
Environment=CLASSPATH=.:/opt/xxx/jre/lib
Environment=PATH=/opt/xxx/jre/bin:/opt/xxx/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
WorkingDirectory=/opt/xxx/bin
RemainAfterExit=yes
ExecStart=/bin/bash -l /opt/xxx/bin/startApp.sh
ExecStop=-/bin/bash -lc "/opt/xxx/bin/stopApp.sh -np"
KillMode=none
[Install]
WantedBy=multi-user.target
--------------------------------------------------------------------------------
The above unit file works for starting and stopping the application both at
boot and via:
systemctl start xxx
systemctl stop xxx
When I check the systemctl service status
$ systemctl list-units -t service
UNIT LOAD ACTIVE SUB DESCRIPTION
xxx.service loaded active exited XXX Application
I think the RemainAfterExit directive tells systemd to show the ACTIVE state
even though the startup script exited.
Both the loaded and active status make sense.
The low-level unit activation state of exited makes sense since the start
script for the application exits after starting the application components.
For some more info:
$ /bin/systemctl status xxx
● xxx.service - XXX Application
Loaded: loaded (/etc/systemd/system/xxx.service; enabled; vendor preset:
disabled)
Active: active (exited) since Mon 2016-12-19 16:15:13 EST; 18h ago
Main PID: 15346 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/xxx.service
├─15402 /opt/xxx/jre/bin/java ...
├─16249 /opt/xxx/jre/bin/java ...
├─16893 /opt/xxx/...
├─16894 /opt/xxx/jre/bin/java ...
├─17146 /bin/sh /opt/xxx/...
├─17173 /opt/xxx/jre/bin/java ...
├─17201 /opt/xxx/...
├─17239 /opt/xxx/...
└─17945 /opt/xxx/jre/bin/java ...
The Main PID: 15346 I assume was the pid for the startup script which exits.
Is there some way I can have systemd monitor the component pids to show ACTIVE
status?
Is there a better way to configure the service unit - given that we have to use
the 3rd party scripts?
Thanks,
Stephen R. Owens
Senior Software Engineer
Massachusetts Office of Information Technology
Commonwealth of Massachusetts
One Ashburton Place, Room 1611
Boston, MA 02108
Tel: 617-626-4513 x24513
Email: [email protected]<mailto:[email protected]>
_______________________________________________
systemd-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/systemd-devel