forked from ochinchina/supervisord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_template.go
143 lines (128 loc) · 2.79 KB
/
config_template.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package main
import (
"io"
"os"
)
var config_template = `[unix_http_server]
file=/tmp/supervisord.sock
#chmod=not support
#chown=not support
username=test1
password={SHA}82ab876d1387bfafe46cc1c8a2ef074eae50cb1d
[inet_http_server]
port=127.0.0.1:9001
username=test1
password=thepassword
[supervisord]
logfile=%(here)s/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=info
pidfile=%(here)s/supervisord.pid
#umask=not support
#nodaemon=not support
#minfds=not support
#minprocs=not support
#nocleanup=not support
#childlogdir=not support
#user=not support
#directory=not support
#strip_ansi=not support
#environment=not support
identifier=supervisor
[program:x]
command=/bin/cat
process_name=%(program_name)s
numprocs=1
#numprocs_start=not support
autostart=true
startsecs=3
startretries=3
autorestart=true
exitcodes=0,2
stopsignal=TERM
stopwaitsecs=10
stopasgroup=true
killasgroup=true
user=user1
redirect_stderr=false
stdout_logfile=AUTO
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=10
stdout_capture_maxbytes=0
stdout_events_enabled=true
stderr_logfile=AUTO
stderr_logfile_maxbytes=50MB
stderr_logfile_backups=10
stderr_capture_maxbytes=0
stderr_events_enabled=false
environment=KEY="val",KEY2="val2"
directory=/tmp
#umask=not support
serverurl=AUTO
[include]
files=/an/absolute/filename.conf /an/absolute/*.conf foo.conf config??.conf
[group:x]
programs=bar,baz
priority=999
[eventlistener:x]
command=/bin/eventlistener
process_name=%(program_name)s
numprocs=1
#numprocs_start=not support
autostart=true
startsecs=3
startretries=3
autorestart=true
exitcodes=0,2
stopsignal=TERM
stopwaitsecs=10
#stopasgroup=not support
#killasgroup=not support
user=user1
redirect_stderr=false
stdout_logfile=AUTO
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=10
stdout_capture_maxbytes=0
stdout_events_enabled=true
stderr_logfile=AUTO
stderr_logfile_maxbytes=50MB
stderr_logfile_backups=10
stderr_capture_maxbytes=0
stderr_events_enabled=false
environment=KEY="val",KEY2="val2"
directory=/tmp
#umask=not support
serverurl=AUTO
buffer_size=10240
events=PROCESS_STATE
#result_handler=not support
[supervisorctl]
serverurl = unix:///tmp/supervisor.sock
username = chris
password = 123
#prompt = not support
`
type InitTemplateCommand struct {
OutFile string `short:"o" long:"output" description:"the output file name" required:"true"`
}
var initTemplateCommand InitTemplateCommand
func (x *InitTemplateCommand) Execute(args []string) error {
f, err := os.Create(x.OutFile)
if err != nil {
return err
}
defer f.Close()
return GenTemplate(f)
}
func GenTemplate(writer io.Writer) error {
_, err := writer.Write([]byte(config_template))
return err
}
func init() {
parser.AddCommand("init",
"initialize a template",
"The init subcommand writes the supported configurations to specified file",
&initTemplateCommand)
}