Created attachment 464922 [details] smartd.service The attached file is a native systemd file for upcoming F15 Feature [1] Please read [2] on how to packaging and installing systemd Service files. To learn more about Systemd daemon see [3]. To view old SysV with the new Systemd site by site see for your component see [4] If you have any question dont hesitate to ask them on this bug report. 1.http://fedoraproject.org/wiki/Features/systemd 2.https://fedoraproject.org/wiki/Systemd_Packaging_Draft 3.http://0pointer.de/public/systemd-man/daemon.html 4.https://fedoraproject.org/wiki/User:Johannbg/QA/Systemd/compatability
I had to use RemainAfterExit=yes because of smartd_opts="-q never" in sysconfig, so daemon don't want to stop correctly systemctl stop smartd.service systemctl status smartd.service smartd.service - Self Monitoring and Reporting Technology (SMART) Daemon Loaded: loaded (/lib/systemd/system/smartd.service) Active: failed since Mon, 06 Dec 2010 05:34:39 +0100; 1s ago Main PID: 2524 (code=exited, status=1/FAILURE) CGroup: name=systemd:/system/smartd.service
(In reply to comment #1) > I had to use RemainAfterExit=yes because of smartd_opts="-q never" in > sysconfig, so daemon don't want to stop correctly could you explain this a little bit more?
AFAIK smartd_opts="-q never" is a default sysconfig option. If this setting is present, smartd.service doesn't start correctly without RemainAfterExit=yes. I guess that it will be really hard to change default sysconfig on all installed systems, so RemainAfterExit=yes appears to be the best choice to provide working systemd service for smartd. We can also remove smartd_opts from smartd command line, but it's probably not the best solution :)
(In reply to comment #3) > AFAIK smartd_opts="-q never" is a default sysconfig option. yes > If this setting is > present, smartd.service doesn't start correctly without RemainAfterExit=yes. and the question is why? smartd -q never starts, forks, terminate, so here it'd require RemainAfterExit=yes, but with smartd -n -q never it does not fork, so I don't see (theoretical) reason why RemainAfterExit=yes is required and it seems to me that if it *is* required, something is wrong
(In reply to comment #3) > AFAIK smartd_opts="-q never" is a default sysconfig option. If this setting is > present, smartd.service doesn't start correctly without RemainAfterExit=yes. > > I guess that it will be really hard to change default sysconfig on all > installed systems, so RemainAfterExit=yes appears to be the best choice to > provide working systemd service for smartd. We can also remove smartd_opts from > smartd command line, but it's probably not the best solution :) Out of curiosity why did you suddenly decide to add -n ( --no-fork ) when starting the daemon which is not done by default in smartd initscript ( daemon $SMARTD_BIN $smartd_opts )? Did setting Type=forking not work as in something like ... [Unit] Description=Self Monitoring and Reporting Technology (SMART) Daemon After=syslog.target [Service] Type=forking EnvironmentFile=/etc/sysconfig/smartmontools ExecStart=/usr/sbin/smartd $smartd_opts PIDFile=/var/lock/subsys/smartd [Install] WantedBy=multi-user.target And btw Michał could you please remember to set mime type to text and link directly to the attachment in the bug instead of the bug itself for easy side by side viewing on https://fedoraproject.org/wiki/User:Johannbg/QA/Systemd/compatability
Unfortunately, I do not know what could be wrong. I made a few script conversions and it's the first case, when I need to use RemainAfterExit for a normal daemon. Lennart, could you help us a little bit?
"Out of curiosity why did you suddenly decide to add -n ( --no-fork ) when starting the daemon which is not done by default in smartd initscript ( daemon $SMARTD_BIN $smartd_opts )?" Lennart suggested to not overuse "Type=forking". "Did setting Type=forking not work as in something like ..." It seems to me that I tried to run smartd this way, but something did not worked. Unfortunately, now I can not check this. "And btw Michał could you please remember to set mime type to text and link directly to the attachment in the bug instead of the bug itself for easy side by side viewing on" Ok
"It seems to me that I tried to run smartd this way, but something did not worked. Unfortunately, now I can not check this." Oh why's that? You could try starting smartd in debug mode ( -d ) and without " RemainAfterExit=yes" to see if spews out something useful BTW Lennart is probably somewhere hiking in Indias now since he will be later presenting on foss.in which is held 14-16 of December so I think he's more or less absent from the internet for the moment..
Hum.. There could be a bug with systemd an qoutation marks in /etc/sysconfig/$options_file as systemd as in systemd does not strip off the quotation marks perhaps it should not? Anyway could you removing the quotation marks in /etc/sysconfig/smartmontools so it becomes smartd_opts=-q never and test your smartd.service file without RemainAfterExit=yes as in [Unit] Description=Self Monitoring and Reporting Technology (SMART) Daemon After=syslog.target [Service] EnvironmentFile=/etc/sysconfig/smartmontools ExecStart=/usr/sbin/smartd -n $smartd_opts [Install] WantedBy=multi-user.target To see if that works?
Ok, I'll try. BTW. I think that this quotation marks bug https://bugzilla.redhat.com/show_bug.cgi?id=617320#c9 should be fixed ASAP, because its occurrence may lead to errors in service files. Is Kay Sievers is the second systemd developer? Maybe he will know what/where to fix? This is probably code that needs to be fixed src/load-fragment.c:1339 static int config_parse_env_file after p = strstrip(l);
(In reply to comment #9) > Hum.. > > There could be a bug with systemd an qoutation marks in > /etc/sysconfig/$options_file as systemd as in systemd does not strip off the > quotation marks perhaps it should not? > > Anyway could you removing the quotation marks in /etc/sysconfig/smartmontools > so it becomes smartd_opts=-q never and test your smartd.service file without > RemainAfterExit=yes as in huh? do you really mean replacing smartd_opts="-q never" with smartd_opts=-q never ? these files are sourced script files, so quotation marks are not optional, they are required. Without them it means just: execute "never" and set smartd_opts to "-q" in its environment. This would be completely wrong. Also don't forget users can changed this value and they used quotation marks (or it would not work) so it's not easy to update.
It was a workaround that was mentioned in comment 9 on 617320 which I shared on but basically I was expecting him to try Type=forking first. Tomaz has since then pointed out that the quotation mark striping is different for ${OPTS} and $OPTS. Difference is described in man systemd.service, at the end of ExecStart= paragraph. As in... "Optionally, if the absolute file name is prefixed with @, the second token will be passed as argv[0] to the executed process, followed by the further arguments specified. If the first token is prefixed with - an exit code of the command normally considered a failure (i.e. non-zero exit status or abormal exit due to signal) is ignored and considered success. If both - and @ are used for the same command the former must preceed the latter. Unless Type=forking is set, the process started via this command line will be considered the main process of the daemon. The command line accepts % specifiers as described in systemd.unit(5). On top of that basic environment variable substitution is supported, where ${FOO} is replaced by the string value of the environment variable of the same name. Also $FOO may appear as separate word on the command line in which case the variable is replaced by its value split at whitespaces. Note that the first argument (i.e. the binary to execute) may not be a variable, and must be a literal and absolute path name."
Ok, quotation marks are causing this problem But I'm not sure if this paragraph form man systemd.service gives us answer how to fix the problem. I tried to run service this way [Service] EnvironmentFile=/etc/sysconfig/smartmontools Type=forking ExecStart=@/usr/sbin/smartd $smartd_opts and IMHO something is wrong systemctl status smartd.service smartd.service - Self Monitoring and Reporting Technology (SMART) Daemon Loaded: loaded (/lib/systemd/system/smartd.service) Active: active (running) since Tue, 07 Dec 2010 10:36:55 +0100; 6min ago Process: 2362 ($smartd_opts, code=exited, status=0/SUCCESS) Main PID: 2364 (smartd) CGroup: name=systemd:/system/smartd.service └ 2364 -q never ps aux | grep 2364 root 2364 0.0 0.0 18876 592 ? S 10:36 0:00 -q never