WL#10441: Add mysqld_safe-functionality to server
Affects: Server-8.0 — Status: Complete
Re-implement parts of the logic currently found in the mysqld_safe script inside the server. Including
- find the full path to executable
- find basedir (mysql_home) from this
- set sharedir and messages dir
- provide short-cuts for the --initialize and --daemonize options
- improve usage of error log during startup
- improve feedback given to users when starting as a daemon (to facilitate integration into the various service management systems)
BUG#75343 is fixed by this worklog.
- Find the full path to executable from argv
- Find basedir (mysql_home) from expanded executable path
- Set sharedir and messages dir based on found basedir
- Support all packages, make install and sandbox run
- -I shortcut for --initialize
- -D shortcut for --daemonize
- Change the default for --log-error to "" when running with --daemonize and not connected to tty
- Ensure that error log output is not lost if error log cannot be redirected
- Inform user about pid and error log location when appropriate
- (Stretch) Identify and remove CMAKE constants made redundant when resolving basedir at runtime
- Existing scripts and setups must continue to work
- Changes should attempt to feel "intuitive" for the user
- -I and -D will become aliases for --initialize and --daemonize
- The name of the error log file and the pid file will be printed to stdout whenever connected to a tty
- Error log messages are dumped to stderr if we fail to open the chosen file
- Add shortcuts to the system variable/option description for --daemonize and --initialize.
- Change the existing test which aborts when running with --daemonize and --log-error is unset and not connected to tty, so that it sets log_error_dest to "" and continues, rather than aborts.
- Use my_access() to ensure that we are actually able to write to the error log before redirecting. This allows user to see error log messages on stderr if the chosen file cannot be written to.
- Clean up error reporting in mysqld::runtime::mysqld_daemonize() to make it easier to diagnose problems. Always print name of error log and pidfile when running with --daemonize and connected to tty.
- Find the full path to the server executable. Do this by
- If it is already a full path, use it as is
- If it is a relative path (at least one directory, possibly . or ..) look it up using my_realpath()
- If it is a bare name, look it up in PATH
- Use the full path to the excutable to obtain the
- bindir as the dir part of the executable path
- basedir (aka mysql_home) as $bindir/..
Copyright (c) 2000, 2022, Oracle Corporation and/or its affiliates. All rights reserved.