description     "{{{ description }}}"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]

respawn
umask {{{umask}}}
{{#nice}}nice {{{nice}}}
{{/nice}}{{#limit_open_files}}limit nofile {{{limit_open_files}}} {{{limit_open_files}}}
{{/limit_open_files}}chroot {{{chroot}}}
chdir {{{chdir}}}

#limit core <softlimit> <hardlimit>
#limit cpu <softlimit> <hardlimit>
#limit data <softlimit> <hardlimit>
#limit fsize <softlimit> <hardlimit>
#limit memlock <softlimit> <hardlimit>
#limit msgqueue <softlimit> <hardlimit>
#limit nice <softlimit> <hardlimit>
#limit nofile <softlimit> <hardlimit>
#limit nproc <softlimit> <hardlimit>
#limit rss <softlimit> <hardlimit>
#limit rtprio <softlimit> <hardlimit>
#limit sigpending <softlimit> <hardlimit>
#limit stack <softlimit> <hardlimit>

{{#prestart}}
pre-start script
  {{{ prestart }}}

  status=$?
  if [ "$status" -gt 0 ] ; then
    echo "Prestart command failed with code $status."

    # Per init(5) docs, simply calling 'stop' will abort this start.
    stop
  fi
end script
{{/prestart}}

script
  # When loading default and sysconfig files, we use `set -a` to make
  # all variables automatically into environment variables.
  set -a
  [ -r "{{{default_file}}}" ] && . "{{{default_file}}}"
  [ -r "{{{sysconfig_file}}}" ] && . "{{{sysconfig_file}}}"
  set +a
  exec chroot --userspec {{{user}}}:{{{group}}} {{{chroot}}} {{{program}}} {{{shell_args}}} >> {{ log_path_stdout }} 2>> {{ log_path_stderr }}
end script
