2
0
Эх сурвалжийг харах

Merge pull request #1500 from kubiko/devel

service life cycle improvements
Lauri Ojansivu 7 жил өмнө
parent
commit
435501fb8e

+ 2 - 2
snap-src/bin/caddy-control

@@ -6,7 +6,7 @@ source $SNAP/bin/wekan-read-settings
 if [ "$CADDY_ENABLED" = "true" ]; then
     env LC_ALL=C caddy -conf=$SNAP_COMMON/Caddyfile -host=localhost:${CADDY_PORT}
 else
-    snapctl stop caddy-service 2>&1 || true
+    echo "caddy is disabled. Stop service"
+    snapctl stop --disable ${SNAP_NAME}.caddy
     # sleep here, in case snapctl fails to stop service so we do not restart too often
-    sleep 60
 fi

+ 2 - 2
snap-src/bin/config

@@ -8,7 +8,7 @@ keys="MONGODB_BIND_UNIX_SOCKET MONGODB_BIND_IP MONGODB_PORT MAIL_URL MAIL_FROM R
 # default values
 DESCRIPTION_MONGODB_BIND_UNIX_SOCKET="mongodb binding unix socket:\n"\
 "\t\t\t Default behaviour will preffer binding over unix socket, to disable unix socket binding set value to 'nill' string\n"\
-"\t\t\t To bind to instance of mongo provided through contect interface set to relative path to the socket inside shared directory"
+"\t\t\t To bind to instance of mongodb provided through content interface,set value to relative path to the socket inside '$SNAP_DATA/shared' directory"
 DEFAULT_MONGODB_BIND_UNIX_SOCKET="$SNAP_DATA/share"
 KEY_MONGODB_BIND_UNIX_SOCKET="mongodb-bind-unix-socket"
 
@@ -36,7 +36,7 @@ DESCRIPTION_PORT="port wekan is exposed at"
 DEFAULT_PORT="8080"
 KEY_PORT="port"
 
-DESCRIPTION_DISABLE_MONGODB="Disable mongodb service: use only if binding to database outside of the snap. Valid values: [true,false]"
+DESCRIPTION_DISABLE_MONGODB="Disable mongodb service: use only if binding to database outside of the ${SNAP_NAME} snap. Valid values: [true,false]"
 DEFAULT_DISABLE_MONGODB="false"
 KEY_DISABLE_MONGODB="disable-mongodb"
 

+ 2 - 1
snap-src/bin/mongodb-control

@@ -4,7 +4,8 @@
 source $SNAP/bin/wekan-read-settings
 
 if [ "true" == "${DISABLE_MONGODB}" ]; then
-    echo "mongodb is disabled. Not starting it"
+    echo "mongodb is disabled. Stop service"
+    snapctl stop --disable ${SNAP_NAME}.mongodb
     exit 0
 fi
 

+ 3 - 8
snap-src/bin/wekan-help

@@ -8,15 +8,10 @@ if [ "$CADDY_ENABLED" = "true" ]; then
 fi
 
 echo -e "Wekan: The open-source Trello-like kanban.\n"
-echo -e "Make sure you have connected all interfaces, check more by calling $ snap interfaces"
+echo -e "Make sure you have connected all interfaces, check more by calling $ snap interfaces ${SNAP_NAME}"
 echo -e "\n"
-echo -e "${SNAP_NAME} has multiple services, to check status/restart/stop use systemctl"
-echo -e "mongodb service:"
-echo -e "\t$ sudo systemctl status/start/stop/restart snap.$SNAP_NAME.mongodb"
-echo -e "wekan service"
-echo -e "\t$ sudo systemctl status/start/stop/restart snap.$SNAP_NAME.wekan"
-echo -e "Optional caddy service"
-echo -e "\t$ sudo systemctl status/start/stop/restart snap.$SNAP_NAME.caddy"
+echo -e "${SNAP_NAME} has multiple services, to check status use systemctl"
+echo -e "\t$ systemctl status snap.$SNAP_NAME.*"
 echo -e "\n"
 echo -e "To make backup of wekan's database use: $ ${SNAP_NAME}.database-backup [backup file]"
 echo -e "\t backup file is optional parameter, if not passed backup is created in directory:"

+ 10 - 1
snap/hooks/configure

@@ -17,10 +17,19 @@ if [ "$value" = "true" ]; then
     port=$(snapctl get port)
     [ "x" != "x${bind_port}" ] && sed -i 's|proxy / localhost:.* {|proxy / localhost:'"${bind_port}"' {|g' $SNAP_COMMON/Caddyfile
     [ "x" != "x$port" ] && sed -i 's|http://:.*|http://:'"${port}"'|g' $SNAP_COMMON/Caddyfile
+    snapctl stop ${SNAP_NAME}.caddy 2>&1 || true
     snapctl start --enable ${SNAP_NAME}.caddy 2>&1 || true
 else
     snapctl stop --disable ${SNAP_NAME}.caddy 2>&1 || true
 fi
 
+value=$(snapctl get disable-mongodb)
+if [ "$value" = "true" ]; then
+    snapctl stop --disable ${SNAP_NAME}.mongodb 2>&1 || true
+else
+    snapctl stop ${SNAP_NAME}.mongodb 2>&1 || true
+    snapctl start --enable ${SNAP_NAME}.mongodb 2>&1 || true
+fi
+
 # restart all services
-snapctl restart ${SNAP_NAME} 2>&1 || true
+snapctl restart ${SNAP_NAME}.wekan 2>&1 || true