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-filecommandline option to router. - add a
pid_fileconfig file option to router.
- FR1
-
if --bootstrap is not specified, setting
--pid-fileon the commandline,pid_fileconfigfile orROUTER_PIDon environment its value MUST be used as location for the pid-file. - FR2
-
--pid-fileon commandline MUST take precedence overpid_filein the config-file. - FR3
-
pid_filein config-file MUST take precedence overROUTER_PIDon 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_folderconfig-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_fileis set, but empty, router MUST fail - FR9
-
if
ROUTER_PIDis set, but empty, router MUST fail - FR10
-
if
--pid-fileis set, but empty, router MUST fail - FR11
- if writing the PID file fails, router MUST fail
If --bootstrap is specified:
- FR12
-
if
--pid-fileis specified, router MUST fail.
Non-failure Scenarios
If --bootstrap is specified:
- FR13
-
ROUTER_PIDenv-var andpid_fileconfig-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.