1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ghost_ynh.git synced 2024-09-03 19:16:02 +02:00

startup script now waits for service availability

This commit is contained in:
Julien Malik 2014-09-01 12:36:31 +02:00
parent c623e708c7
commit e980bbd883
2 changed files with 23 additions and 11 deletions

View file

@ -68,6 +68,25 @@ do_start()
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some dime.
ghost_http_request_result=1
ghost_path=$(yunohost app setting ghostblog path)
count=0
max_count=60
while [ "$ghost_http_request_result" != "0" ]
do
[ "$VERBOSE" != no ] && log_action_cont_msg "."
if [ "$count" -ge $max_count ]; then
[ "$VERBOSE" != no ] && log_action_cont_msg "Timeout"
return 3
fi
curl -kL -X GET http://localhost:2368${ghost_path} > /dev/null 2>&1
ghost_http_request_result=$?
sleep 1
count=$(expr $count + 1)
done
}
#
@ -114,11 +133,11 @@ do_stop()
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
[ "$VERBOSE" != no ] && log_action_begin_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
0|1) [ "$VERBOSE" != no ] && log_action_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_action_end_msg 1 ;;
esac
;;
stop)

View file

@ -122,16 +122,9 @@ sudo service nginx reload
sudo yunohost app ssowatconf
echo "Registering admin..."
sleep 10
admin_name=$(sudo yunohost user list --json | python ../conf/user_getname.py $admin)
admin_mail=$(sudo yunohost user list --json | python ../conf/user_getmail.py $admin)
# first round initialize
curl -kL -X GET http://127.0.0.1:2368${path%/}
curl -kL -X GET http://127.0.0.1:2368${path%/}
# setup admin details
curl -kL -X POST http://127.0.0.1:2368${path%/}/ghost/api/v0.1/authentication/setup/ \
curl -kL -X POST http://localhost:2368${path%/}/ghost/api/v0.1/authentication/setup/ \
--data-urlencode "setup[0][name]=$admin_name" \
--data-urlencode "setup[0][email]=$admin_mail" \
--data-urlencode "setup[0][password]=$password" \