Hello, I am new to systemd and the maintainer of the file distribution software AFD (http://www.dwd.de/AFD) and I am trying to adapt this application to systemd. The problem I am unable to solve is that doing a reboot, poweroff or halt, all process get a SIGTERM before systemd calls the command supplied by ExecStop. If I do a 'systemctl stop afd.service' everything works as expected. I have searched the web for a solution and have tried all the different service Type=, unit After=/Before= combination, but failed so far. I must be doing something obviously wrong, but unable to see what and need help please.
The service/unit file looks as follows: [Unit] Description=Automatic File Distributor After=basic.target [Service] RemainAfterExit=yes Type=oneshot ExecStart=-/etc/init.d/afd start ExecStop=-/etc/init.d/afd stop KillMode=none StandardOutput=syslog+console StandardError=syslog+console [Install] WantedBy=multi-user.target /etc/init.d/afd is a shell script that starts one or more instances of the AFD under different users. The users are configured in /etc/sysconfig/afd and are started via the following command: su - $afduser -c "<cmd start/sop AFD>" To speed things up a bit the script forks for each user to start/stop the AFD instances. The script /etc/init.d/afd is just initiating thinks, but always waits for the command to complete. AFD itself has an init process (init_afd) that then starts several other process and monitors them. In /etc/init.d/afd I have added the following line in the beginning, before it wants to do the shutdown: echo "Before: ps -u afd: `ps -u $afduser`" >> /var/log/afd.log And this then shows the following: Before: ps -u afd: PID TTY TIME CMD 1258 ? 00:00:00 init_afd 1260 ? 00:00:00 system_log <defunct> 1261 ? 00:00:00 event_log <defunct> 1262 ? 00:00:00 receive_log <defunct> 1263 ? 00:00:00 transfer_log <defunct> 1264 ? 00:00:00 trans_db_log <defunct> 1265 ? 00:00:00 archive_watch <defunct> 1266 ? 00:00:00 input_log <defunct> 1267 ? 00:00:00 output_log <defunct> 1268 ? 00:00:00 delete_log <defunct> 1269 ? 00:00:00 production_log <defunct> 1270 ? 00:00:00 distribution_lo <defunct> 1271 ? 00:00:00 amg <defunct> 1272 ? 00:00:00 aldad <defunct> 1287 ? 00:00:00 afd_stat <defunct> 1288 ? 00:00:00 fd <defunct> 1289 ? 00:00:00 dir_check <defunct> All the process have received a SIGTERM before (or during the execution) of the script. Any idea what I am doing wrong, or what else I can try to do a proper shutdown of this application under systemd? Thanks in advance, Holger _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel