[MDEV-18238] --pre-script and --post-script options for mysqld_safe Created: 2019-01-14  Updated: 2021-02-25

Status: Open
Project: MariaDB Server
Component/s: Scripts & Clients
Fix Version/s: N/A

Type: Task Priority: Minor
Reporter: Juan Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: None


 Description   

We're requesting some options to be added to mysqld_safe; --pre-script, and --post-script. These options will enable a script to be ran before re-starting the mysqld process after a crash (so we can load the keys), and then another script to be ran after startup / crash recovery is complete.



 Comments   
Comment by Daniel Black [ 2019-01-15 ]

what form of script? What should be the state of mysqld when each of these is run? Why mysqld_safe? mysqld might be a better option depending on what you are trying to achieve.

Comment by Geoff Montee (Inactive) [ 2019-01-25 ]

The "--pre-script" part could probably already be done with mysqld_safe's --mysqld option.

$ mysqld_safe --help
Usage: /usr/bin/mysqld_safe [OPTIONS]
...
  --mysqld=FILE              Use the specified file as mysqld
...

https://mariadb.com/kb/en/library/mysqld_safe/#specifying-mysqld

And then the "mysqld" that you pass to this option could probably just be a script that does something like:

mysqld_pre_script.sh
mysqld $@

I don't think there is currently a way to tell mysqld_safe to run a script after mysqld finishes startup/crash recovery though.

Comment by Geoff Montee (Inactive) [ 2019-02-13 ]

For the post-startup/crash recovery request, maybe it would make sense to add a new mysqld option similar to init_file that runs a shell script after the server starts up? Maybe it could be called something like init_shell or init_script to keep the name kind of similar to init_file and init_connect?

https://mariadb.com/kb/en/library/server-system-variables/#init_file

Comment by Daniel Black [ 2019-02-13 ]

If it was systemd you could just drop in a ExecStartPost script like

/etc/systemd/system/mariadb.service.d/loadkeys.conf:

[Service]
ExecStartPost=mysql -e 'source ... /loadkeys.sql'

Generated at Thu Feb 08 08:42:34 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.