<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>{{ .Title }}</string>
	<key>ProgramArguments</key>
	<array>
		{{- if .Interpreter }}
		<string>{{ .Interpreter }}</string>
		{{- end }}
		<string>{{ .Local }}/opt/{{ .Name }}/{{ .Exec }}</string>
	  {{- if .Argv }}
		{{- range $arg := .Argv }}
		<string>{{ $arg }}</string>
		{{- end }}
	  {{- end }}
	</array>
	{{- if .Envs }}
	<key>EnvironmentVariables</key>
	<dict>
		{{- range $key, $value := .Envs }}
		<key>{{ $key }}</key>
		<string>{{ $value }}</string>
		{{- end }}
	</dict>
	{{- end }}

	{{if .User -}}
	<key>UserName</key>
	<string>{{ .User }}</string>
	<key>GroupName</key>
	<string>{{ .Group }}</string>
	<key>InitGroups</key>
	<true/>

	{{end -}}
	<key>RunAtLoad</key>
	<true/>
	{{ if .Restart -}}
	<key>KeepAlive</key>
	<true/>
	<!--dict>
		<key>Crashed</key>
		<true/>
		<key>NetworkState</key>
		<true/>
		<key>SuccessfulExit</key>
		<false/>
	</dict-->

	{{ end -}}
	{{ if .Production -}}
	<key>SoftResourceLimits</key>
	<dict>
		<key>NumberOfFiles</key>
		<integer>8192</integer>
	</dict>
	<key>HardResourceLimits</key>
	<dict/>

	{{ end -}}
	<key>WorkingDirectory</key>
	<string>{{ .Local }}/opt/{{ .Name }}</string>

	<key>StandardErrorPath</key>
	<string>{{ .LogDir }}/{{ .Name }}.log</string>
	<key>StandardOutPath</key>
	<string>{{ .LogDir }}/{{ .Name }}.log</string>
</dict>
</plist>
