From 8b7b7d8033a8db8eebc8859132330f59ec29de43 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 15 Jun 2022 22:54:44 +0800 Subject: [PATCH] supervisor dev --- plugins/supervisor/conf/supervisor.conf | 170 ++++++++++++++++++ plugins/supervisor/ico.png | Bin 0 -> 9639 bytes plugins/supervisor/index.html | 22 +++ plugins/supervisor/index.py | 230 ++++++++++++++++++++++++ plugins/supervisor/info.json | 18 ++ plugins/supervisor/install.sh | 62 +++++++ plugins/supervisor/js/supervisor.js | 29 +++ 7 files changed, 531 insertions(+) create mode 100644 plugins/supervisor/conf/supervisor.conf create mode 100644 plugins/supervisor/ico.png create mode 100755 plugins/supervisor/index.html create mode 100755 plugins/supervisor/index.py create mode 100755 plugins/supervisor/info.json create mode 100755 plugins/supervisor/install.sh create mode 100755 plugins/supervisor/js/supervisor.js diff --git a/plugins/supervisor/conf/supervisor.conf b/plugins/supervisor/conf/supervisor.conf new file mode 100644 index 000000000..930c17b90 --- /dev/null +++ b/plugins/supervisor/conf/supervisor.conf @@ -0,0 +1,170 @@ +; Sample supervisor config file. +; +; For more information on the config file, please see: +; http://supervisord.org/configuration.html +; +; Notes: +; - Shell expansion ("~" or "$HOME") is not supported. Environment +; variables can be expanded using this syntax: "%(ENV_HOME)s". +; - Quotes around values are not supported, except in the case of +; the environment= options as shown below. +; - Comments must have a leading space: "a=b ;comment" not "a=b;comment". +; - Command will be truncated if it looks like a config file comment, e.g. +; "command=bash -c 'foo ; bar'" will truncate to "command=bash -c 'foo ". +; +; Warning: +; Paths throughout this example file use /tmp because it is available on most +; systems. You will likely need to change these to locations more appropriate +; for your system. Some systems periodically delete older files in /tmp. +; Notably, if the socket file defined in the [unix_http_server] section below +; is deleted, supervisorctl will be unable to connect to supervisord. + +[unix_http_server] +file=/var/run/supervisor.sock +;chmod=0700 ; socket file mode (default 0700) +;chown=nobody:nogroup ; socket file uid:gid owner +;username=user ; default is no username (open server) +;password=123 ; default is no password (open server) + +; Security Warning: +; The inet HTTP server is not enabled by default. The inet HTTP server is +; enabled by uncommenting the [inet_http_server] section below. The inet +; HTTP server is intended for use within a trusted environment only. It +; should only be bound to localhost or only accessible from within an +; isolated, trusted network. The inet HTTP server does not support any +; form of encryption. The inet HTTP server does not use authentication +; by default (see the username= and password= options to add authentication). +; Never expose the inet HTTP server to the public internet. + +;[inet_http_server] ; inet (TCP) server disabled by default +;port=127.0.0.1:9001 ; ip_address:port specifier, *:port for all iface +;username=user ; default is no username (open server) +;password=123 ; default is no password (open server) + +[supervisord] +logfile=/var/log/supervisor.log +logfile_maxbytes=50MB ; max main logfile bytes b4 rotation; default 50MB +logfile_backups=10 ; # of main logfile backups; 0 means none, default 10 +loglevel=info ; log level; default info; others: debug,warn,trace +pidfile=/var/run/supervisor.pid +nodaemon=false ; start in foreground if true; default false +silent=false ; no logs to stdout if true; default false +minfds=1024 ; min. avail startup file descriptors; default 1024 +minprocs=200 ; min. avail process descriptors;default 200 +;umask=022 ; process file creation umask; default 022 +;user=supervisord ; setuid to this UNIX account at startup; recommended if root +;identifier=supervisor ; supervisord identifier, default is 'supervisor' +;directory=/tmp ; default is not to cd during start +;nocleanup=true ; don't clean up tempfiles at start; default false +;childlogdir=/tmp ; 'AUTO' child log dir, default $TEMP +;environment=KEY="value" ; key value pairs to add to environment +;strip_ansi=false ; strip ansi escape codes in logs; def. false + +; The rpcinterface:supervisor section must remain in the config file for +; RPC (supervisorctl/web interface) to work. Additional interfaces may be +; added by defining them in separate [rpcinterface:x] sections. + +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +; The supervisorctl section configures how supervisorctl will connect to +; supervisord. configure it match the settings in either the unix_http_server +; or inet_http_server section. + +[supervisorctl] +serverurl=unix:///var/run/supervisor.sock +;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket +;username=chris ; should be same as in [*_http_server] if set +;password=123 ; should be same as in [*_http_server] if set +;prompt=mysupervisor ; cmd line prompt (default "supervisor") +;history_file=~/.sc_history ; use readline history if available + +; The sample program section below shows all possible program subsection values. +; Create one or more 'real' program: sections to be able to control them under +; supervisor. + +;[program:theprogramname] +;command=/bin/cat ; the program (relative uses PATH, can take args) +;process_name=%(program_name)s ; process_name expr (default %(program_name)s) +;numprocs=1 ; number of processes copies to start (def 1) +;directory=/tmp ; directory to cwd to before exec (def no cwd) +;umask=022 ; umask for process (default None) +;priority=999 ; the relative start priority (default 999) +;autostart=true ; start at supervisord start (default: true) +;startsecs=1 ; # of secs prog must stay up to be running (def. 1) +;startretries=3 ; max # of serial start failures when starting (default 3) +;autorestart=unexpected ; when to restart if exited after running (def: unexpected) +;exitcodes=0 ; 'expected' exit codes used with autorestart (default 0) +;stopsignal=QUIT ; signal used to kill process (default TERM) +;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10) +;stopasgroup=false ; send stop signal to the UNIX process group (default false) +;killasgroup=false ; SIGKILL the UNIX process group (def false) +;user=chrism ; setuid to this UNIX account to run the program +;redirect_stderr=true ; redirect proc stderr to stdout (default false) +;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO +;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB) +;stdout_logfile_backups=10 ; # of stdout logfile backups (0 means none, default 10) +;stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0) +;stdout_events_enabled=false ; emit events on stdout writes (default false) +;stdout_syslog=false ; send stdout to syslog with process name (default false) +;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO +;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB) +;stderr_logfile_backups=10 ; # of stderr logfile backups (0 means none, default 10) +;stderr_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0) +;stderr_events_enabled=false ; emit events on stderr writes (default false) +;stderr_syslog=false ; send stderr to syslog with process name (default false) +;environment=A="1",B="2" ; process environment additions (def no adds) +;serverurl=AUTO ; override serverurl computation (childutils) + +; The sample eventlistener section below shows all possible eventlistener +; subsection values. Create one or more 'real' eventlistener: sections to be +; able to handle event notifications sent by supervisord. + +;[eventlistener:theeventlistenername] +;command=/bin/eventlistener ; the program (relative uses PATH, can take args) +;process_name=%(program_name)s ; process_name expr (default %(program_name)s) +;numprocs=1 ; number of processes copies to start (def 1) +;events=EVENT ; event notif. types to subscribe to (req'd) +;buffer_size=10 ; event buffer queue size (default 10) +;directory=/tmp ; directory to cwd to before exec (def no cwd) +;umask=022 ; umask for process (default None) +;priority=-1 ; the relative start priority (default -1) +;autostart=true ; start at supervisord start (default: true) +;startsecs=1 ; # of secs prog must stay up to be running (def. 1) +;startretries=3 ; max # of serial start failures when starting (default 3) +;autorestart=unexpected ; autorestart if exited after running (def: unexpected) +;exitcodes=0 ; 'expected' exit codes used with autorestart (default 0) +;stopsignal=QUIT ; signal used to kill process (default TERM) +;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10) +;stopasgroup=false ; send stop signal to the UNIX process group (default false) +;killasgroup=false ; SIGKILL the UNIX process group (def false) +;user=chrism ; setuid to this UNIX account to run the program +;redirect_stderr=false ; redirect_stderr=true is not allowed for eventlisteners +;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO +;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB) +;stdout_logfile_backups=10 ; # of stdout logfile backups (0 means none, default 10) +;stdout_events_enabled=false ; emit events on stdout writes (default false) +;stdout_syslog=false ; send stdout to syslog with process name (default false) +;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO +;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB) +;stderr_logfile_backups=10 ; # of stderr logfile backups (0 means none, default 10) +;stderr_events_enabled=false ; emit events on stderr writes (default false) +;stderr_syslog=false ; send stderr to syslog with process name (default false) +;environment=A="1",B="2" ; process environment additions +;serverurl=AUTO ; override serverurl computation (childutils) + +; The sample group section below shows all possible group values. Create one +; or more 'real' group: sections to create "heterogeneous" process groups. + +;[group:thegroupname] +;programs=progname1,progname2 ; each refers to 'x' in [program:x] definitions +;priority=999 ; the relative start priority (default 999) + +; The [include] section can just contain the "files" setting. This +; setting can list multiple files (separated by whitespace or +; newlines). It can also contain wildcards. The filenames are +; interpreted as relative to this file. Included files *cannot* +; include files themselves. + +[include] +files = /www/server/supervisor/conf.d/*.ini diff --git a/plugins/supervisor/ico.png b/plugins/supervisor/ico.png new file mode 100644 index 0000000000000000000000000000000000000000..229e387524f12ea56edb6b9ad925203902405d9c GIT binary patch literal 9639 zcmXYX1z1$y^Y`6_rIzjn3F!`L7NkK+KvI_OZmA`tl@J7#SW;93Bt*$YLJ;@@f~0hJ zvq--8_kZ4f_SwBVGxyBgIWwO#JLe=D>T8k^F%kg)K%%XsW()uj@Dc(L;DKM({*}%E zzz%4ushEW3?-dMX&1$?pxXad|T@jX>YO(mIDzaFeQu$@BkQMIqZr1D%yuo~j$u8OJ zdw2zRvuep@*K1FmD3tC;TeMDn`5f%~tnFS3`Q8=qBUI`gp~N#W6^qw?bUgP;41uGZ zH(J03U1uc+Ay*wy-z%QsCs5)pQQ|JibhBv|B(<1a9bgW~0n*0#M=U4?0Nt_0yG`Rj zF9>X7Hv8~uVT-U4v~BKq9S#O|D1~BxCtP+y(J3Rl-Z4OcYkOXafIPi*r#S4eN zb2o;~nRM|Xz)6d{-UY>|X=t(lSLmQ9Q#%zyh&hmlXK{*E*>90sgl?90gc$~F=Dn%~ zLyC$t!6oZlu^)A{*{-z=~I15$447SC+S3I ziT$wu5u4c*l&V4kB{h_~*5$%sr(M#(oFTd1pSdV9{Rq{8w_+*WqBgjqe7;JrC?vYIZf*+5O5Hwxk^zY7CV=6)5 z)E<1^6lCsPOa%stpkv;C`}}2+0Ft^3ieNJ(yB#GF$&~~dY;MwG4l z25m#hCD_QWfNp6X&eX3~TedR~oYK;VzMI}ob`T`1WS0hsmT@AB*cGelf4fYPpHFvD z?#$+tmy{an@AQCkXr6lWbl&(Wi(dpq{?vB6TXFj;AFL2hn7D)<)bZurvqWa&&KkPb z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d00001 diff --git a/plugins/supervisor/index.html b/plugins/supervisor/index.html new file mode 100755 index 000000000..dae556285 --- /dev/null +++ b/plugins/supervisor/index.html @@ -0,0 +1,22 @@ +
+
+
+

服务

+

进程管理

+

配置

+

子配置

+

日志

+
+
+
+
+
+
+ +
+ \ No newline at end of file diff --git a/plugins/supervisor/index.py b/plugins/supervisor/index.py new file mode 100755 index 000000000..0bb230c54 --- /dev/null +++ b/plugins/supervisor/index.py @@ -0,0 +1,230 @@ +# coding:utf-8 + +import sys +import io +import os +import time + +sys.path.append(os.getcwd() + "/class/core") +import mw + +app_debug = False +if mw.isAppleSystem(): + app_debug = True + + +def getPluginName(): + return 'supervisor' + + +def getPluginDir(): + return mw.getPluginDir() + '/' + getPluginName() + + +def getServerDir(): + return mw.getServerDir() + '/' + getPluginName() + + +def getInitDFile(): + if app_debug: + return '/tmp/' + getPluginName() + return '/etc/init.d/' + getPluginName() + + +def getConf(): + path = getServerDir() + "/supervisor.conf" + return path + + +def getConfTpl(): + path = getPluginDir() + "/conf/supervisor.conf" + return path + + +def getInitDTpl(): + path = getPluginDir() + "/init.d/" + getPluginName() + ".tpl" + return path + + +def getArgs(): + args = sys.argv[2:] + tmp = {} + args_len = len(args) + + if args_len == 1: + t = args[0].strip('{').strip('}') + t = t.split(':') + tmp[t[0]] = t[1] + elif args_len > 1: + for i in range(len(args)): + t = args[i].split(':') + tmp[t[0]] = t[1] + + return tmp + + +def status(): + data = mw.execShell( + "ps -ef|grep supervisor |grep -v grep | awk '{print $2}'") + + if data[0] == '': + return 'stop' + return 'start' + + +def initDreplace(): + + # initD_path = getServerDir() + '/init.d' + # if not os.path.exists(initD_path): + # os.mkdir(initD_path) + # file_bin = initD_path + '/' + getPluginName() + + # file_tpl = getInitDTpl() + # initd replace + # content = mw.readFile(file_tpl) + # content = content.replace('{$SERVER_PATH}', service_path) + # mw.writeFile(file_bin, content) + # mw.execShell('chmod +x ' + file_bin) + + if not os.path.exists(getServerDir() + "/conf.d"): + os.mkdir(getServerDir() + "/conf.d") + + if not os.path.exists(getServerDir() + '/supervisor.conf'): + # config replace + service_path = os.path.dirname(os.getcwd()) + conf_content = mw.readFile(getConfTpl()) + conf_content = conf_content.replace('{$SERVER_PATH}', service_path) + mw.writeFile(getServerDir() + '/supervisor.conf', conf_content) + + return True + + +def start(): + initDreplace() + cmd = 'supervisord -c ' + getServerDir() + '/supervisor.conf' + # print(cmd) + data = mw.execShell(cmd) + # print(data) + if data[1] == '': + return 'ok' + return 'fail' + + +def stop(): + file = initDreplace() + data = mw.execShell(file + ' stop') + if data[1] == '': + return 'ok' + return 'fail' + + +def restart(): + file = initDreplace() + data = mw.execShell(file + ' restart') + if data[1] == '': + return 'ok' + return 'fail' + + +def reload(): + file = initDreplace() + data = mw.execShell(file + ' reload') + if data[1] == '': + return 'ok' + return 'fail' + + +def runInfo(): + cmd = getServerDir() + "/bin/redis-cli info" + data = mw.execShell(cmd)[0] + res = [ + 'tcp_port', + 'uptime_in_days', # 已运行天数 + 'connected_clients', # 连接的客户端数量 + 'used_memory', # Redis已分配的内存总量 + 'used_memory_rss', # Redis占用的系统内存总量 + 'used_memory_peak', # Redis所用内存的高峰值 + 'mem_fragmentation_ratio', # 内存碎片比率 + 'total_connections_received', # 运行以来连接过的客户端的总数量 + 'total_commands_processed', # 运行以来执行过的命令的总数量 + 'instantaneous_ops_per_sec', # 服务器每秒钟执行的命令数量 + 'keyspace_hits', # 查找数据库键成功的次数 + 'keyspace_misses', # 查找数据库键失败的次数 + 'latest_fork_usec' # 最近一次 fork() 操作耗费的毫秒数 + ] + data = data.split("\n") + result = {} + for d in data: + if len(d) < 3: + continue + t = d.strip().split(':') + if not t[0] in res: + continue + result[t[0]] = t[1] + return mw.getJson(result) + + +def initdStatus(): + if not app_debug: + if mw.isAppleSystem(): + return "Apple Computer does not support" + initd_bin = getInitDFile() + if os.path.exists(initd_bin): + return 'ok' + return 'fail' + + +def initdInstall(): + import shutil + if not app_debug: + if mw.isAppleSystem(): + return "Apple Computer does not support" + + source_bin = initDreplace() + initd_bin = getInitDFile() + shutil.copyfile(source_bin, initd_bin) + mw.execShell('chmod +x ' + initd_bin) + mw.execShell('chkconfig --add ' + getPluginName()) + return 'ok' + + +def initdUinstall(): + if not app_debug: + if mw.isAppleSystem(): + return "Apple Computer does not support" + + mw.execShell('chkconfig --del ' + getPluginName()) + initd_bin = getInitDFile() + os.remove(initd_bin) + return 'ok' + + +def runLog(): + return getServerDir() + '/data/redis.log' + +if __name__ == "__main__": + func = sys.argv[1] + if func == 'status': + print(status()) + elif func == 'start': + print(start()) + elif func == 'stop': + print(stop()) + elif func == 'restart': + print(restart()) + elif func == 'reload': + print(reload()) + elif func == 'initd_status': + print(initdStatus()) + elif func == 'initd_install': + print(initdInstall()) + elif func == 'initd_uninstall': + print(initdUinstall()) + elif func == 'run_info': + print(runInfo()) + elif func == 'conf': + print(getConf()) + elif func == 'run_log': + print(runLog()) + else: + print('error') diff --git a/plugins/supervisor/info.json b/plugins/supervisor/info.json new file mode 100755 index 000000000..dc7d61cd2 --- /dev/null +++ b/plugins/supervisor/info.json @@ -0,0 +1,18 @@ +{ + "sort": 7, + "ps": "[开发中...]一个Python开发的通用的进程管理程序", + "name": "supervisor", + "title": "supervisor", + "shell": "install.sh", + "versions":["1.0"], + "updates":["1.0"], + "tip": "soft", + "checks": "server/supervisor", + "path": "server/supervisor", + "display": 1, + "author": "python", + "date": "2022-06-15", + "home": "https://pypi.org/project/supervisor/", + "type": 0, + "pid": "4" +} \ No newline at end of file diff --git a/plugins/supervisor/install.sh b/plugins/supervisor/install.sh new file mode 100755 index 000000000..d4a57e8b9 --- /dev/null +++ b/plugins/supervisor/install.sh @@ -0,0 +1,62 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + +install_tmp=${rootPath}/tmp/mw_install.pl +VERSION=$2 + + +sysName=`uname` +echo "use system: ${sysName}" + +if [ ${sysName} == "Darwin" ]; then + OSNAME='macos' +elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then + OSNAME='centos' +elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then + OSNAME='fedora' +elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then + OSNAME='debian' +elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then + OSNAME='ubuntu' +elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then + OSNAME='raspbian' +else + OSNAME='unknow' +fi + +Install_app() +{ + echo '正在安装脚本文件...' > $install_tmp + mkdir -p $serverPath/source + mkdir -p $serverPath/supervisor + + echo 'supervisor install...' + if [ "centos" == "$OSNAME" ] || [ "fedora" == "$OSNAME" ];then + yum install supervisor -y + elif [ "ubuntu" == "$OSNAME" ] || [ "debian" == "$OSNAME" ] ;then + apt install supervisor -y + else + brew install supervisor + fi + + echo '安装完成' > $install_tmp +} + +Uninstall_app() +{ + rm -rf $serverPath/supervisor + echo "Uninstall_redis" > $install_tmp +} + +action=$1 +if [ "${1}" == 'install' ];then + Install_app +else + Uninstall_app +fi diff --git a/plugins/supervisor/js/supervisor.js b/plugins/supervisor/js/supervisor.js new file mode 100755 index 000000000..9d5b100d2 --- /dev/null +++ b/plugins/supervisor/js/supervisor.js @@ -0,0 +1,29 @@ + + +function myPost(method,args,callback, title){ + + var _args = null; + if (typeof(args) == 'string'){ + _args = JSON.stringify(str2Obj(args)); + } else { + _args = JSON.stringify(args); + } + + var _title = '正在获取...'; + if (typeof(title) != 'undefined'){ + _title = title; + } + + var loadT = layer.msg(_title, { icon: 16, time: 0, shade: 0.3 }); + $.post('/plugins/run', {name:'supervisor', func:method, args:_args}, function(data) { + layer.close(loadT); + if (!data.status){ + layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']}); + return; + } + + if(typeof(callback) == 'function'){ + callback(data); + } + },'json'); +} \ No newline at end of file