I am trying to create systemd service file for Flume, have created /etc/systemd/system/flume-ng.service
with following contents
[Unit]
Description=Apache Flume
[Service]
Environment=FLUME_CLASSPATH=/opt/flume/current/lib/
ExecStart=/usr/bin/nohup /usr/bin/flume-ng agent -c /etc/flume-ng/conf -f /etc/flume-ng/conf/flume.conf --name a1 &
[Install]
WantedBy=multi-user.target
which start the Flume service but how do I stop it as a service ?
In this case I had to kill with PID.
thanks
systemctl is the systemd command for controlling how services start on a Linux system. A service can be enabled, disabled, or masked, and it can be configured to start at boot, on demand, manually, or prevented from starting under any circumstances.
Control whether the service starts with the system You can use the enable and disable subcommands to manage those defaults. Reboot the system with reboot sudo systemctl reboot , and the service won't automatically start.
4 Identifying and stopping processes in systemd services The systemd-cgls command displays all processes that belong to a systemd service, and systemctl SIGNAL PROCESS stops them. The D-Bus service is the message bus for communication between systemd clients and the systemd manager that is running as pid 1.
You can just execute systemctl stop flume-ng.service
. When executed, the default action is sending SIGTERM
to the main process and wait until a configurable time to see if the processes has been terminated. If the process doesn't terminate, then systemd sends SIGKILL
signal which does the job. If the main process has forked off other processes, systemd will take them down too since they all live in the same cgroup.
You do not need to have ExecStop=
directive unless you have a different way of shutting down your service.
You need to put in a ExecStop
option in the [Service]
section with the command you want to use to stop the service.
Something like:
[Service]
Environment=FLUME_CLASSPATH=/opt/flume/current/lib/
ExecStart=/usr/bin/nohup /usr/bin/flume-ng agent -c /etc/flume-ng/conf -f /etc/flume-ng/conf/flume.conf --name a1 &
ExecStop=/usr/bin/flume-ng agent stop
or whatever the command is to stop the flume-ng
Then you can stop the service with systemctl stop flume-ng
.
Read the manual at https://www.freedesktop.org/software/systemd/man/systemd.service.html for the full set of options available to control the service.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With