mirror of
https://github.com/YunoHost-Apps/ihatemoney_ynh.git
synced 2024-09-03 19:26:15 +02:00
Deduplicate code to wait for server to start
This commit is contained in:
parent
7a98e93227
commit
fa2989c8d7
5 changed files with 12 additions and 19 deletions
|
@ -10,12 +10,19 @@ pip_dependencies=(
|
||||||
'PyMySQL>=0.9,<1.1'
|
'PyMySQL>=0.9,<1.1'
|
||||||
)
|
)
|
||||||
|
|
||||||
### Constants
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
wait_gunicorn_start() {
|
||||||
|
# line_match isn't enough because ihatemoney may stop if database upgrades
|
||||||
|
for _ in {1..20}; do
|
||||||
|
test -S /tmp/budget.gunicorn_$app.sock && break
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
__ynh_python_venv_setup() {
|
__ynh_python_venv_setup() {
|
||||||
local -A args_array=( [d]=venv_dir= [p]=packages= )
|
local -A args_array=( [d]=venv_dir= [p]=packages= )
|
||||||
local venv_dir
|
local venv_dir
|
||||||
|
|
|
@ -52,6 +52,7 @@ ynh_script_progression --message="Starting a systemd service..." --weight=5
|
||||||
|
|
||||||
# Start a systemd service
|
# Start a systemd service
|
||||||
ynh_systemd_action --service_name=$app --action="start"
|
ynh_systemd_action --service_name=$app --action="start"
|
||||||
|
wait_gunicorn_start
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -92,12 +92,7 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||||
|
|
||||||
# Start a systemd service
|
# Start a systemd service
|
||||||
ynh_systemd_action --service_name=$app --action="start" --line_match="Listening at"
|
ynh_systemd_action --service_name=$app --action="start" --line_match="Listening at"
|
||||||
|
wait_gunicorn_start
|
||||||
# line_match isn't enough because ihatemoney may stop if database upgrades
|
|
||||||
for _ in {1..20}; do
|
|
||||||
test -S /tmp/budget.gunicorn_$app.sock && break
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -64,12 +64,7 @@ yunohost service add $app --description="$app daemon for IHateMoney" --log=syste
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --line_match="Listening at"
|
ynh_systemd_action --service_name=$app --action="start" --line_match="Listening at"
|
||||||
|
wait_gunicorn_start
|
||||||
# line_match isn't enough because ihatemoney may stop if database upgrades
|
|
||||||
for _ in {1..20}; do
|
|
||||||
test -S /tmp/budget.gunicorn_$app.sock && break
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
|
|
@ -162,12 +162,7 @@ yunohost service add $app --description="$app daemon for IHateMoney" --log=syste
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --line_match="Listening at"
|
ynh_systemd_action --service_name=$app --action="start" --line_match="Listening at"
|
||||||
|
wait_gunicorn_start
|
||||||
# line_match isn't enough because ihatemoney may stop if database upgrades
|
|
||||||
for _ in {1..20}; do
|
|
||||||
test -S /tmp/budget.gunicorn_$app.sock && break
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
Loading…
Add table
Reference in a new issue