Created
May 1, 2017 08:38
-
-
Save ejpcmac/ed11ba399025608e136d9f4f71616e9d to your computer and use it in GitHub Desktop.
FreeBSD startup script for Elixir/OTP release
This file contains 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
#!/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