Main: ignore the "pid_file" setting if started as systemd service
Commit 552c30eae
caused problems for those people who still had a
"pid_file" setting (even though that is obsolete with systemd),
because now /run/mpd is owned by root:root (our mpd.service has no
User=mpd directive, so systemd starts MPD as root).
To work around this problem, and to be able to keep
RuntimeDirectory=mpd (which solved a problem of other MPD users), the
best compromise seems to just ignore the "pid_file" setting when it is
of no use.
This commit is contained in:
parent
8754d705a1
commit
a4e4217204
1
NEWS
1
NEWS
|
@ -2,6 +2,7 @@ ver 0.23.4 (not yet released)
|
||||||
* output
|
* output
|
||||||
- alsa: add option "thesycon_dsd_workaround" to work around device bug
|
- alsa: add option "thesycon_dsd_workaround" to work around device bug
|
||||||
* fix crash or debug builds if startup fails
|
* fix crash or debug builds if startup fails
|
||||||
|
* ignore the "pid_file" setting if started as systemd service
|
||||||
* Windows
|
* Windows
|
||||||
- enable the "openmpt" decoder plugin
|
- enable the "openmpt" decoder plugin
|
||||||
|
|
||||||
|
|
12
src/Main.cxx
12
src/Main.cxx
|
@ -145,9 +145,19 @@ static void
|
||||||
glue_daemonize_init(const CommandLineOptions &options,
|
glue_daemonize_init(const CommandLineOptions &options,
|
||||||
const ConfigData &config)
|
const ConfigData &config)
|
||||||
{
|
{
|
||||||
|
auto pid_file = config.GetPath(ConfigOption::PID_FILE);
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
if (options.systemd && pid_file != nullptr) {
|
||||||
|
pid_file = nullptr;
|
||||||
|
fprintf(stderr,
|
||||||
|
"Ignoring the 'pid_file' setting in systemd mode\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
daemonize_init(config.GetString(ConfigOption::USER),
|
daemonize_init(config.GetString(ConfigOption::USER),
|
||||||
config.GetString(ConfigOption::GROUP),
|
config.GetString(ConfigOption::GROUP),
|
||||||
config.GetPath(ConfigOption::PID_FILE));
|
std::move(pid_file));
|
||||||
|
|
||||||
if (options.kill)
|
if (options.kill)
|
||||||
daemonize_kill();
|
daemonize_kill();
|
||||||
|
|
Loading…
Reference in New Issue