Explorar o código

add-提交supervisor文件夹

Zhipeng %!s(int64=4) %!d(string=hai) anos
pai
achega
b856927844
Modificáronse 3 ficheiros con 75 adicións e 0 borrados
  1. 26 0
      supervisor/install.sh
  2. 15 0
      supervisor/server.conf
  3. 34 0
      supervisor/uninstall.sh

+ 26 - 0
supervisor/install.sh

@@ -0,0 +1,26 @@
+#!/bin/bash
+
+
+#Read parameters
+echo "Please input the configuration file name"
+read conf
+echo "Please input the program"
+read program
+echo "Please input the process_name"
+read process_name
+echo "Please input the user"
+read user
+echo "Please input the command"
+read command
+echo "Please input the directory"
+read directory
+
+#Copy the configuration file in the supervisor.d folder
+served="/etc/supervisord.d"
+if [ -f "$served/$conf" ]
+then
+echo "The service has already existed"
+exit 1
+else
+# The first position is server.conf File installation directory
+cp server.conf $served/$conf

+ 15 - 0
supervisor/server.conf

@@ -0,0 +1,15 @@
+#!/bin/bash
+[program:PROGRAM]
+process_name = PROCESS_NAME
+command= COMMAND
+directory= DIRECTORY
+autostart = true
+startsecs = 5
+autorestart = true
+startretries = 3
+user = USER
+redirect_stderr = true
+stdout_logfile_maxbytes = 20MB
+stdout_logfile_backups = 10
+stdout_logfile = /var/log/test-server.log
+

+ 34 - 0
supervisor/uninstall.sh

@@ -0,0 +1,34 @@
+#!/bin/bash
+echo "Please input the service you want to uninstall"
+read conf
+served="/etc/supervisord.d"
+if [ ! -f "$served/$conf" ]
+then
+echo "The service is not existing"
+exit 1
+fi
+
+
+echo "Are you sure uninstall ${conf}? y/n"
+read flag
+
+until [ "y" == ${flag} ] || [ "n" == ${flag} ]
+do
+        echo "Please input y/n again"
+        read flag
+done
+
+
+case $flag in
+"y")
+        rm -rf $served/$conf
+        echo "The service has uninstalled"
+        ;;
+"n")
+        echo "Exit"
+        exit 0
+        ;;
+*)
+        echo "Error,exit uninstall"
+        ;;
+esac