1

This question already has an answer here:

I have a aaa.service file (controlling the JBoss), that besides other regular stuff contains

[Service]
Type=forking
ExecStart=/my/script start
ExecReload=/my/script restart
ExecStop=/my/script stop
PIDFile=...

/my/script start creates the PID-file and service aaa status shows it issuing a strange warning:

Supervising process xxx which is not our child. We'll most likely not notice when it exits.

Full output:

   Loaded: loaded (/etc/systemd/system/aaa.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2019-01-22 20:55:16 CET; 34min ago
  Process: 32435 ExecStart=/my/script start (code=exited, status=0/SUCCESS)
 Main PID: 32542
    Tasks: 0 (limit: 512)
   CGroup: /system.slice/aaa.service

Jan 22 20:54:56 I011-830 su[32447]: (to aaa) root on none
Jan 22 20:54:56 I011-830 su[32447]: pam_unix(su-l:session): session opened for user aaa by (uid=0)
Jan 22 20:55:16 I011-830 aaa[32435]: Starting JBoss application server: Starting JBoss application server:
Jan 22 20:55:16 I011-830 systemd[1]: aaa.service: Supervising process 32542 which is not our child. We'll most likely not notice when it exits.

Now my actual problem is, that if the process get killed other then by issuing service aaa stop, the systemd doesn't detect it. Even more it claims, that it's running and don't want to start it again:

# cat <pid-file>
No such file or directory
# service aaa status
   Loaded: loaded (/etc/systemd/system/aaa.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2019-01-22 20:55:16 CET; 40min ago
  Process: 32435 ExecStart=/konsens/app/aaa/init/aaastart (code=exited, status=0/SUCCESS)
 Main PID: 32542
    Tasks: 0 (limit: 512)
   CGroup: /system.slice/aaa.service
 ...
# service aaa start
# <--- Instant return, no process started

How can I achieve following goals?

  • systemd should be able to start and stop my service
  • service aaa status should show the status of the process regardless if it was started by systemd or manually issuing /my/service start
  • systemd should be able to start service after it was killed manually
  • systemd should be able to stop service, that I have started manually

marked as duplicate by elbarna, RalfFriedl, msp9011, Mr Shunz, Thomas Jan 23 at 11:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

How can I achieve following goals? 1 systemd should be able to start and stop my service

Most distributions have backwards compatibility so you can store your service in /etc/init.d/ if you don't want to make a native service.

2 service aaa status should show the status of the process regardless if it was started by systemd or manually issuing /my/service start

One way to do this is to add a check in your script to call systemctl start aaa.service if it was not called that way to begin with. a trap can be used for exit.

3 systemd should be able to start service after it was killed manually

solved by #2

4 systemd should be able to stop service, that I have started manually

solved by #2

Not the answer you're looking for? Browse other questions tagged or ask your own question.