Skip to content

Instantly share code, notes, and snippets.

@ejpcmac
Created May 1, 2017 08:38
Show Gist options
  • Save ejpcmac/ed11ba399025608e136d9f4f71616e9d to your computer and use it in GitHub Desktop.
Save ejpcmac/ed11ba399025608e136d9f4f71616e9d to your computer and use it in GitHub Desktop.
FreeBSD startup script for Elixir/OTP release
#!/bin/sh
#
# PROVIDE: my_app
# REQUIRE: networking
# KEYWORD:
. /etc/rc.subr
name="my_app"
rcvar="${name}_enable"
install_dir="/usr/local/opt/${name}"
version=$(cat ${install_dir}/releases/start_erl.data | cut -d' ' -f2)
command="${install_dir}/bin/${name}"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
status_cmd="${name}_status"
load_rc_config $name
: ${my_app_enable:="no"}
: ${my_app_user:=${name}}
: ${my_app_node_name:="${name}@127.0.0.1"}
my_app_run() {
HOME="$install_dir" \
LC_ALL=fr_FR.UTF-8 \
NODE_NAME="${my_app_node_name}" \
su -m "$my_app_user" -c "$command $1"
}
my_app_start() {
my_app_run start
}
my_app_stop() {
my_app_run stop
}
my_app_status() {
ping_result=`my_app_run ping`
echo "$ping_result"
case "$ping_result" in
*pong*)
echo "$name is running."
;;
esac
}
load_rc_config $name
run_rc_command "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment