fbf82ae62fe03f69af0114011c0d6848a83d4fb3
- Author
- everbird <stephen.zhuang@gmail.com>
- Committer
- everbird <stephen.zhuang@gmail.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/supervisor/_supervisorctl b/plugins/supervisor/_supervisorctl
2new file mode 100644
3index 0000000000000000000000000000000000000000..d159f20e07f9a384e47e4cc16b78cce80aeeeef6
4--- /dev/null
5+++ b/plugins/supervisor/_supervisorctl
6@@ -0,0 +1,136 @@
7+#compdef supervisorctl
8+
9+typeset -A opt_args
10+local context state line
11+
12+_supervisorctl() {
13+ _arguments -s -S \
14+ {--configuration,-c}"[configuration file path (default /etc/supervisor.conf)]:FILENAME:_files" \
15+ {--help,-h}"[print usage message and exit]:" \
16+ {--interactive,-i}"[start an interactive shell after executing commands]" \
17+ {--serverurl,-s}"[URL on which supervisord server is listening (default "http://localhost:9001").]" \
18+ {--username,-u}"[username to use for authentication with server]:USERNAME:_users" \
19+ {--password,-p}"[password to use for authentication with server]:PASSWORD:" \
20+ {--history-file,-r}"[keep a readline history (if readline is available)]:FILENAME:_files" \
21+ "*::supervisorctl commands:_supervisorctl_command"
22+}
23+
24+(( $+functions[_supervisorctl_command] )) ||
25+_supervisorctl_command() {
26+ local cmd ret=1
27+
28+ (( $+supervisorctl_cmds )) || _supervisorctl_cmds=(
29+ "add:Activates any updates in config for process/group" \
30+ "avail:Display all configured processes" \
31+ "clear:Clear process/multiple-process/all-process log files" \
32+ "exit:Exit the supervisor shell." \
33+ "fg:Connect to a process in foreground mode" \
34+ "maintail:tail of supervisor main log file" \
35+ "open:Connect to a remote supervisord process. (for UNIX domain socket, use unix:///socket/path)" \
36+ "pid:Get the PID of supervisord." \
37+ "quit:Exit the supervisor shell." \
38+ "reload:Restart the remote supervisord." \
39+ "remove:Removes process/group from active config" \
40+ "reread:Reload the daemon's configuration files" \
41+ "restart:Restart process or group." \
42+ "shutdown:Shut the remote supervisord down." \
43+ "start:Start process or groups." \
44+ "status:Get process status info." \
45+ "stop:Stop process or group." \
46+ "tail:tail of process stdout" \
47+ "update:Reload config and add/remove as necessary" \
48+ "version:Show the version of the remote supervisord process" \
49+ "help:Show help" \
50+ )
51+
52+ if (( CURRENT == 1 )); then
53+ _describe -t commands 'supervisorctl subcommand' _supervisorctl_cmds \
54+ || compadd "$@" - ${(s.:.)${(j.:.)_supervisorctl_syns}}
55+ else
56+ local curcontext="$curcontext"
57+
58+ cmd="${${_supervisorctl_cmds[(r)$words[1]:*]%%:*}:-${(k)_supervisorctl_syns[(r)(*:|)$words[1](:*|)]}}"
59+ if (( $#cmd )); then
60+ curcontext="${curcontext%:*:*}:supervisorctl-${cmd}:"
61+ _call_function ret _supervisorctl_$cmd || _message 'no more arguments'
62+ else
63+ _message "unknown supervisorctl command: $words[1]"
64+ fi
65+ return ret
66+ fi
67+}
68+
69+# get supervisor contoroll processes
70+(( $+functions[_get_supervisor_procs] )) ||
71+_get_supervisor_procs() {
72+ local cache_policy
73+ zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
74+ if [[ -z "$cache_policy" ]]; then
75+ zstyle ":completion:${curcontext}:" cache-policy _supervisor_procs_caching_policy
76+ fi
77+
78+ if ( [[ ${+_supervisor_procs} -eq 0 ]] || _cache_invalid supervisor_procs ) \
79+ && ! _retrieve_cache supervisor_procs; then
80+
81+ _supervisor_procs=(${${(f)"$(supervisorctl status >/dev/null 2>&1 | awk -F' ' '{print $1}')"}})
82+ _store_cache supervisor_procs _supervisor_procs
83+ fi
84+
85+ local expl
86+ _wanted supervisor_procs expl 'supervisor processes' compadd -a _supervisor_procs
87+}
88+
89+_supervisor_procs_caching_policy() {
90+ local -a oldp
91+ oldp=( "$1"(Nmw+1) )
92+ (( $#oldp ))
93+}
94+
95+(( $+functions[_supervisorctl_add] )) ||
96+_supervisorctl_add() {
97+ _arguments -s \
98+ "--help[use help system]" \
99+ "*::supervisorctl commands:_supervisorctl"
100+}
101+
102+(( $+functions[_supervisorctl_help] )) ||
103+_supervisorctl_help() {
104+ _arguments -s \
105+ "*:supervisorctl commands:_supervisorctl"
106diff --git a/plugins/supervisor/_supervisord b/plugins/supervisor/_supervisord
107new file mode 100644
108index 0000000000000000000000000000000000000000..34d27805dd1f9d1d3444786073c93e86c44eda31
109--- /dev/null
110+++ b/plugins/supervisor/_supervisord
111@@ -0,0 +1,32 @@
112+#compdef supervisord
113+
114+typeset -A opt_args
115+local context state line
116+
117+_arguments \
118+ {--configuration,-c}"[configuration file]:FILENAME:_files" \
119+ {--nodaemon,-n}"[run in the foreground (same as 'nodaemon true' in config file)]" \
120+ {--help,-h}"[print this usage message and exit]:" \
121+ {--user,-u}"[run supervisord as this user]:USER:_users" \
122+ {--umask,-m}"[use this umask for daemon subprocess (default is 022)]" \
123+ {--directory,-d}"[directory to chdir to when daemonized]" \
124+ {--logfile,-l}"[use FILENAME as logfile path]:FILENAME:_files" \
125+ {--logfile_maxbytes,-y}"[use BYTES to limit the max size of logfile]" \
126+ {--logfile_backups,-z}"[number of backups to keep when max bytes reached]" \
127+ {--loglevel,-e}"[use LEVEL as log level (debug,info,warn,error,critical)]:level:->levels" \
128+ {--pidfile,-j}"[write a pid file for the daemon process to FILENAME]:FILENAME:_files" \
129+ {--identifier,-i}"[identifier used for this instance of supervisord]" \
130+ {--childlogdir,-q}"[the log directory for child process logs]:child log directory:_files -/" \
131+ {--nocleanup,-k}"[prevent the process from performing cleanup (removal of old automatic child log files) at startup.]" \
132+ {--minfds,-a}"[the minimum number of file descriptors for start success]" \
133+ {--strip_ansi,-t}"[strip ansi escape codes from process output]" \
134+ "--minprocs[the minimum number of processes available for start success]" \
135+ "--profile_options[run supervisord under profiler and output results based on OPTIONS, which is a comma-sep'd list of 'cumulative', 'calls', and/or 'callers', e.g. 'cumulative,callers')]" \
136+ "*::args:_gnu_generic"
137+
138+case $state in
139+levels)
140+ levels=("debug" "info" "warn" "error" "critical")
141+ _describe -t levels 'supervisord levels' levels && return 0
142+ ;;
143+esac
144diff --git a/plugins/supervisor/supervisor.plugin.zsh b/plugins/supervisor/supervisor.plugin.zsh
145new file mode 100644
146index 0000000000000000000000000000000000000000..cf1997c5be62ffeebc99253cced7608415e38e4e
147--- /dev/null
148+++ b/plugins/supervisor/supervisor.plugin.zsh
149@@ -0,0 +1 @@
150+# DECLARION: This plugin was created by hhatto. What I did is just making a portal from https://bitbucket.org/hhatto/zshcompfunc4supervisor.