Selaa lähdekoodia

fix: kill watcher function [skip ci]

Nicolas Meienberger 2 vuotta sitten
vanhempi
commit
93188b662c
3 muutettua tiedostoa jossa 5 lisäystä ja 9 poistoa
  1. 3 3
      scripts/common.sh
  2. 2 1
      scripts/stop.sh
  3. 0 5
      scripts/watcher.sh

+ 3 - 3
scripts/common.sh

@@ -54,7 +54,7 @@ function ensure_linux() {
 
 
 function clean_logs() {
 function clean_logs() {
     # Clean logs folder
     # Clean logs folder
-    logs_folder="${ROOT_FOLDER}/logs"
+    local logs_folder="${ROOT_FOLDER}/logs"
 
 
     # Create the folder if it doesn't exist
     # Create the folder if it doesn't exist
     if [[ ! -d "${logs_folder}" ]]; then
     if [[ ! -d "${logs_folder}" ]]; then
@@ -64,7 +64,7 @@ function clean_logs() {
     if [ "$(find "${logs_folder}" -maxdepth 1 -type f | wc -l)" -gt 0 ]; then
     if [ "$(find "${logs_folder}" -maxdepth 1 -type f | wc -l)" -gt 0 ]; then
         echo "Cleaning logs folder..."
         echo "Cleaning logs folder..."
 
 
-        files=($(ls -d "${logs_folder}"/* | xargs -n 1 basename | sed 's/\///g'))
+        local files=($(ls -d "${logs_folder}"/* | xargs -n 1 basename | sed 's/\///g'))
 
 
         for file in "${files[@]}"; do
         for file in "${files[@]}"; do
             echo "Removing ${file}"
             echo "Removing ${file}"
@@ -74,7 +74,7 @@ function clean_logs() {
 }
 }
 
 
 function kill_watcher() {
 function kill_watcher() {
-    watcher_pid="$(ps aux | grep "scripts/watcher" | grep -v grep | awk '{print $2}')"
+    local watcher_pid="$(ps aux | grep "scripts/watcher" | grep -v grep | awk '{print $2}')"
 
 
     # kill it if it's running
     # kill it if it's running
     if [[ -n $watcher_pid ]]; then
     if [[ -n $watcher_pid ]]; then

+ 2 - 1
scripts/stop.sh

@@ -16,7 +16,7 @@ export COMPOSE_HTTP_TIMEOUT=240
 # Stop all installed apps if there are any
 # Stop all installed apps if there are any
 apps_folder="${ROOT_FOLDER}/apps"
 apps_folder="${ROOT_FOLDER}/apps"
 if [ "$(find "${apps_folder}" -maxdepth 1 -type d | wc -l)" -gt 1 ]; then
 if [ "$(find "${apps_folder}" -maxdepth 1 -type d | wc -l)" -gt 1 ]; then
-  apps_names=($(ls -d ${apps_folder}/*/ | xargs -n 1 basename | sed 's/\///g'))
+  apps_names=($(ls -d "${apps_folder}"/*/ | xargs -n 1 basename | sed 's/\///g'))
 
 
   for app_name in "${apps_names[@]}"; do
   for app_name in "${apps_names[@]}"; do
     # if folder ${ROOT_FOLDER}/app-data/app_name exists, then stop app
     # if folder ${ROOT_FOLDER}/app-data/app_name exists, then stop app
@@ -29,6 +29,7 @@ else
   echo "No app installed that can be stopped."
   echo "No app installed that can be stopped."
 fi
 fi
 
 
+kill_watcher
 echo "Stopping Docker services..."
 echo "Stopping Docker services..."
 echo
 echo
 docker compose down --remove-orphans --rmi local
 docker compose down --remove-orphans --rmi local

+ 0 - 5
scripts/watcher.sh

@@ -6,8 +6,6 @@ ROOT_FOLDER="${PWD}"
 WATCH_FILE="${ROOT_FOLDER}/state/events"
 WATCH_FILE="${ROOT_FOLDER}/state/events"
 
 
 function clean_events() {
 function clean_events() {
-    echo "Cleaning events..."
-
     # Create the file if it doesn't exist
     # Create the file if it doesn't exist
     if [[ ! -f "${WATCH_FILE}" ]]; then
     if [[ ! -f "${WATCH_FILE}" ]]; then
         touch "${WATCH_FILE}"
         touch "${WATCH_FILE}"
@@ -43,8 +41,6 @@ function run_command() {
 
 
     local result=$?
     local result=$?
 
 
-    echo "Command ${command_path} exited with code ${result}"
-
     if [[ $result -eq 0 ]]; then
     if [[ $result -eq 0 ]]; then
         set_status "$id" "success"
         set_status "$id" "success"
     else
     else
@@ -105,7 +101,6 @@ function select_command() {
         return 0
         return 0
     fi
     fi
 
 
-    echo "Unknown command ${command}"
     return 0
     return 0
 }
 }