Current section
Files
Jump to
Current section
Files
priv/example/priv/custom/templates/rc.template
#!/bin/sh
# --------------------------------------------------------------------------------------
# CUSTOM TEMPLATE
# --------------------------------------------------------------------------------------
#
# PROVIDE: {{ app_name }}
# REQUIRE: DAEMON
# KEYWORD: shutdown
. /etc/rc.subr
name={{ app_name }}
rcvar=${name}_enable
load_rc_config $name
pidfile="/var/run/${name}.pid"
procname="{{ pkg_proc_name }}"
confdir="{{ pkg_config_dir }}"
logfile="/var/log/${name}.log"
export PATH={{ pkg_path_extensions }}:$PATH
{{ app_name }}_env_file="{{ pkg_config_dir }}/{{ pkg_env_file }}"
command="{{ pkg_prefix }}/libexec/{{ app_name }}/{{ pkg_command }}"
command_args="{{ pkg_command_args }}"
start_precmd="${name}_prestart"
start_postcmd="${name}_poststart"
start_cmd="${name}_start"
remote_cmd="${name}_remote"
extra_commands="remote"
{{ pkg_app_name_uppercase }}_CONF_DIR="${confdir}"
: ${RELEASE_TMP:="/var/run/${name}"}
: ${ERL_CRASH_DUMP:="${RELEASE_TMP}/${name}_erl_crash.dump"}
{{ app_name }}_prestart()
{
if [ ! -d "${RELEASE_TMP}" ]; then
echo "Creating ${RELEASE_TMP}."
mkdir $RELEASE_TMP
chmod 740 $RELEASE_TMP
echo "Setting ${RELEASE_TMP} owner to {{ pkg_user_name }}."
chown -R {{ pkg_user_name }}:{{ pkg_user_name }} $RELEASE_TMP
fi
}
{{ app_name }}_poststart()
{
pid="$(cat ${pidfile})"
echo "Service ${name} started as pid ${pid}."
}
{{ app_name }}_start()
{
export {{ pkg_app_name_uppercase }}_CONF_DIR RELEASE_TMP ERL_CRASH_DUMP
rm -f ${pidfile}
daemon -t $name -p $pidfile -f -H -o $logfile -u {{ pkg_user_name }} {{ pkg_daemon_flags }} env PATH=$PATH $command $command_args
}
{{ app_name }}_remote()
{
export TERM=xterm
env PATH=$PATH $command shell
}
run_rc_command "$@"
# key1={{ pair_key1 }}
# key2={{ pair_key2 }}