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
b1204dbd3d
commit
907a2af4bb
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
|
||||||
|
|
|
@ -50,6 +50,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" --log_path=systemd
|
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd
|
||||||
|
wait_gunicorn_start
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -88,12 +88,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" --log_path="systemd" --line_match="Listening at"
|
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --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
|
||||||
|
|
|
@ -58,12 +58,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" --log_path="systemd" --line_match="Listening at"
|
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --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
|
||||||
|
|
|
@ -155,12 +155,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" --log_path="systemd" --line_match="Listening at"
|
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --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