Created
September 30, 2016 14:26
-
-
Save jippi/5fff79368ca6d8a0d438d84bc1a8a92f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Generated by consul-template | |
# | |
# Project Name: {{PROJECT_NAME}} | |
# Project environment: {{APP_ENV}} | |
# | |
{{- with node -}} | |
{{- $nodeName := .Node.Node -}} | |
{{ range $key, $pairs := tree "apps/{{PROJECT_NAME}}/supervisor" | byKey -}} | |
{{- $processType := $pairs.process_type.Value | print -}} | |
{{- $matchType := regexMatch $processType $nodeName -}} | |
{{- $emptyMatch := not $processType -}} | |
{{- $gotProcs := $pairs.numprocs.Value -}} | |
{{- if (and $gotProcs (or $emptyMatch $matchType)) -}} | |
{{- $numprocs := $pairs.numprocs.Value | parseInt -}} | |
{{- range $i := loop 0 $numprocs }} | |
[program:{{PROJECT_NAME}}_{{- $key -}}_{{- printf "%02d" $i -}}] | |
command = {{ $pairs.command.Value }} | |
directory = {{ if $pairs.directory.Value | print -}}{{- $pairs.directory.Value -}}{{- else -}}{{HTDOCS}}/app{{- end }} | |
environment = {{ if $pairs.environment.Value | print -}}{{- $pairs.environment.Value -}}{{- end }} | |
stopsignal = {{ if $pairs.stopsignal.Value | print -}}{{- $pairs.stopsignal.Value -}}{{- else -}}TERM{{- end }} | |
numprocs = 1 | |
autostart = true | |
autorestart = true | |
startretries = 10 | |
user = www-data | |
startsecs = 3 | |
redirect_stderr = true | |
stdout_logfile_maxbytes = 5MB | |
stdout_logfile_backups = 1 | |
stderr_logfile_maxbytes = 5MB | |
stderr_logfile_backups = 1 | |
stopwaitsecs = 60 | |
{{ end -}} | |
{{- else }} | |
# Program "{{$key}}" with process_type "{{$processType}}" ignored since it does not match "{{$nodeName}}" or got no "numprocs" key | |
{{- end -}} | |
{{- end -}} | |
{{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template { | |
source = "{{TEMPLATE_DIR}}/supervisor.ctmpl" | |
destination = "/etc/supervisor/conf.d/{{PROJECT_NAME}}.conf" | |
command = "test -f /usr/local/bin/supervisorctl && supervisorctl update" | |
wait = "3s:10s" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment