Add script to schedule an optimize on hydra's tables daily
This commit is contained in:
parent
cf632ec6e6
commit
012bd5e415
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<creole>
|
||||
<variables>
|
||||
<family name="optimize_hydra" description="Optimize sur les tables d'Hydra">
|
||||
<variable name="description" type="string" hidden="True"><value>Optimize sur les tables de la base Hydra</value></variable>
|
||||
<variable name="day" type="schedule" description="Périodicité d'exécution"><value>daily</value></variable>
|
||||
<variable name="mode" type="schedulemod" hidden="True"><value>post</value></variable>
|
||||
</family>
|
||||
</variables>
|
||||
<constraints>
|
||||
<!-- Désactive les optimize si on est pas sur la machine qui fait les backups -->
|
||||
<fill name='calc_multi_condition' target='schedule.optimize_hydra.day'>
|
||||
<param>non</param>
|
||||
<param type='eole' name='condition_1'>dbEnableBackup</param>
|
||||
<param name='match'>none</param>
|
||||
<param name='mismatch'>daily</param>
|
||||
</fill>
|
||||
</constraints>
|
||||
</creole>
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/bash
|
||||
|
||||
DESC="Optimize sur les tables d'Hydra"
|
||||
|
||||
. /usr/share/eole/schedule/config.sh
|
||||
|
||||
echo "Begin date: $(date)"
|
||||
|
||||
day=$(date '+%u') # 1 == Monday
|
||||
|
||||
case $day in
|
||||
1)
|
||||
tables='hydra_oauth2_access'
|
||||
;;
|
||||
2)
|
||||
tables='hydra_oauth2_oidc'
|
||||
;;
|
||||
3)
|
||||
tables='hydra_oauth2_code'
|
||||
;;
|
||||
4)
|
||||
tables='hydra_oauth2_authentication_request'
|
||||
;;
|
||||
5)
|
||||
tables='hydra_oauth2_consent_request'
|
||||
;;
|
||||
6)
|
||||
tables='hydra_oauth2_logout_request, hydra_oauth2_consent_request_handled'
|
||||
;;
|
||||
7)
|
||||
tables='hydra_oauth2_authentication_session, hydra_oauth2_authentication_request_handled, hydra_oauth2_pkce'
|
||||
;;
|
||||
*)
|
||||
echo 'Unexpected error. Day: $day'
|
||||
exit 1
|
||||
esac
|
||||
|
||||
mysql --defaults-file=/etc/mysql/debian.cnf hydra <<EOF
|
||||
OPTIMIZE TABLE $tables;
|
||||
EOF
|
||||
|
||||
exit_val=$?
|
||||
|
||||
echo "End date: $(date)"
|
||||
|
||||
exit $exit_val
|
Loading…
Reference in New Issue