WL#13705: add pid-file option
Motivation
MySQL Router allows writing PID-files on startup only through setting the ROUTER_PID
environment variable to a filename the pid-file shall be written to. (It is ignored if router is called with --bootstrap
.)
Other server apps like MySQL Server use --pid-file
to pass the location to store the PID file.
Goal
- add a
--pid-file
commandline option to router. - add a
pid_file
config file option to router.
- FR1
-
if --bootstrap is not specified, setting
--pid-file
on the commandline,pid_file
configfile orROUTER_PID
on environment its value MUST be used as location for the pid-file. - FR2
-
--pid-file
on commandline MUST take precedence overpid_file
in the config-file. - FR3
-
pid_file
in config-file MUST take precedence overROUTER_PID
on environment. - FR4
- if the location of the pid-file is empty, no pid-file MUST be written
- FR5
-
if the location of the pid-file is not absolute, its path is relative to
runtime_folder
config-variable. - FR6
- if the location of the pid-file is NOT empty and the pid-file does not exist, a numeric PID MUST be written to the specified location
Failure Scenarios
If --bootstrap
is not specified:
- FR7
- if the pid-file already exists, router MUST fail
- FR8
-
if
pid_file
is set, but empty, router MUST fail - FR9
-
if
ROUTER_PID
is set, but empty, router MUST fail - FR10
-
if
--pid-file
is set, but empty, router MUST fail - FR11
- if writing the PID file fails, router MUST fail
If --bootstrap
is specified:
- FR12
-
if
--pid-file
is specified, router MUST fail.
Non-failure Scenarios
If --bootstrap
is specified:
- FR13
-
ROUTER_PID
env-var andpid_file
config-option MUST be ignored.
Commandline option
mysqlrouter --pid-file=<filename>
Configuration file
[DEFAULT]
pid_file=<filename>
Note on current behaviour
At present, MySQL Router only writes the PID-file if ROUTER_PID environment is set. By default, it will not create the PID-file. After this WL, this default behaviour should be extended to create a PID-file only if at least one of the {ROUTER_PID env var, --pid-file cmdline option, pid_file config option} is provided.
Also, PID-file will be written only when Router runs in its "regular" (not bootstrap) mode. Bootstrap mode never writes a PID-file.