You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both upstart and systemd have more advanced features than init.d, and make service scripts easier. For example, for the stop() function in init.d script:
stop() {
# Try a few times to kill TERM the program
if status ; then
pid=`cat "$pidfile"`
echo "Killing $name (pid $pid) with SIGTERM"
kill -TERM $pid
# Wait for it to exit.
for i in 1 2 3 4 5 6 7 8 9 ; do
echo "Waiting $name (pid $pid) to die..."
status || break
sleep 1
done
if status ; then
if [[ $KILL_ON_STOP_TIMEOUT -eq 1 ]] ; then
echo "Timeout reached. Killing $name (pid $pid) with SIGKILL. This may result in data loss."
kill -KILL $pid
echo "$name killed with SIGKILL."
else
echo "$name stop failed; still running."
fi
else
echo "$name stopped."
fi
fi
}
A little hard, right? And not do well with perform a stop operate. I often meet that when I want logstash to restart, but start two processes(the old process stop failed, while start a new one).
sudo service logstash restart
Killing logstash (pid 21829) with SIGTERM
Waiting logstash (pid 21829) to die...
Waiting logstash (pid 21829) to die...
Waiting logstash (pid 21829) to die...
Waiting logstash (pid 21829) to die...
Waiting logstash (pid 21829) to die...
Waiting logstash (pid 21829) to die...
Waiting logstash (pid 21829) to die...
Waiting logstash (pid 21829) to die...
Waiting logstash (pid 21829) to die...
logstash stop failed; still running.
logstash started.
But both upstart and systemd could handle this problem easily. For example, upstart has a built-in kill timeout stanza that could force kill a service if still running after timeout. And do not need to write a stop() function manually.
Today, modern Linux distributions introduce systemd as the default service manager(Ubuntu 16.04 or later, Debian 8 or later, RHEL/CentOS 7 or later). So logstash should prepare new systemd script for the distributions which support systemd.
The text was updated successfully, but these errors were encountered:
I use jordansissel/pleaserun for generating most of this lately. I would be happy if we did the same.
However, for rpm/deb packaging, it becomes extremely annoying to ship multiple service definitions (sysv init, upstart, systemd, et al) with a single rpm or deb.
You can roughly achieve a systemd or upstart for logstash today with pleaserun, something like:
Both
upstart
andsystemd
have more advanced features thaninit.d
, and make service scripts easier. For example, for thestop()
function ininit.d
script:A little hard, right? And not do well with perform a stop operate. I often meet that when I want logstash to restart, but start two processes(the old process stop failed, while start a new one).
But both
upstart
andsystemd
could handle this problem easily. For example,upstart
has a built-in kill timeout stanza that could force kill a service if still running after timeout. And do not need to write astop()
function manually.And I find that in fact, logstash has a Ubuntu upstart script: https://github.com/elastic/logstash/blob/master/pkg/logstash.upstart.ubuntu. But why not using for now?
Today, modern Linux distributions introduce
systemd
as the default service manager(Ubuntu 16.04 or later, Debian 8 or later, RHEL/CentOS 7 or later). So logstash should prepare newsystemd
script for the distributions which supportsystemd
.The text was updated successfully, but these errors were encountered: