On Mar 4, 2019, at 10:15 PM, Jobst Schmalenbach <jo...@barrett.com.au> wrote: > > I have to (re-)write many bootup scripts to move a bunch of servers from > CentOS6 to CentOS7 > > In sysvinit the "echo_success" and "echo_failure" used to do this. > > What is the equivalent for systemd?
First off, processes started by systemd unit files don’t necessarily echo anything at all, and when they do, that output is captured by journald, not sent straight to the system console. Systemd infers success or failure of the started service in one of several ways: - process exit code - contents of a PID file - existence of a FIFO - etc. Your code in the unit file tells systemd which method to use. Systemd prints out the green “OK” when the rules you’ve set up in the unit file match actual conditions on the server. This is also how systemd can provide automatic service restarts: you’ve told it what it looks like when a service is “up”, so it can implicitly detect “down” and restart the dead service for you. In the old scheme, that’s something you had to hand-code, and it was outside of the scope of SysVInit besides, so most services didn’t have that ability. With systemd, you can set this up with a line or three in the unit file, and systemd then handles it for you. You should start reading here: https://www.freedesktop.org/software/systemd/man/systemd.service.html#Options The Type value you select affects which “up” detection methods are sensible. For example, if you say your service is a “forking” type, it doesn’t make sense for systemd to be told to look for a nonzero exit status. Read the rest of that page as well. There’s a lot of power to take advantage of in systemd. Resist the temptation to just launch your old shell script via systemd. It’s better to rewrite its imperative logic in declarative form within the unit file, so you get full benefit of systemd’s power. _______________________________________________ CentOS mailing list CentOS@centos.org https://lists.centos.org/mailman/listinfo/centos