After doing a lot of searching and digging, I was finally able to modify and create a start up script for big brother bot for anyone who is running it on FreeBSD.
Credits go to
wernerdevThe basic jist of how I have big brother bot setup on my server is as follows.
I have my start up script saved to:
/usr/local/etc/rc.d/b3
#!/bin/sh
#
# PROVIDE: b3
# REQUIRE: mysql
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# b3_enable (bool): Set to NO by default.
# Set it to YES to enable b3.
#
. /etc/rc.subr
name="b3"
rcvar=`set_rcvar`
load_rc_config ${name}
: ${b3_enable:="NO"}
: ${b3_user:="b3"}
: ${b3_dir:="/home/b3/bigbrotherbot"}
: ${b3_chdir:="${b3_dir}"}
: ${b3_pid:="${b3_dir}/b3.pid"}
status_cmd="${name}_status"
stop_cmd="${name}_stop"
command="/usr/sbin/daemon"
command_args="-f -p ${b3_pid} python ${b3_dir}/b3_run.py -c ${b3_dir}/conf/b3.xml"
# Ensure user is root when running this script
if [ `id -u` != "0" ]; then
echo "Oops, you should be root before running this!"
exit 1
fi
verify_b3_pid() {
# Make sure the pid corresponds to the b3 process
pid=`cat ${b3_pid} 2>/dev/null`
ps -p ${pid} | grep -q "python ${b3_dir}/b3_run.py"
return $?
}
# Try to stop b3 cleanly
b3_stop() {
echo "Stopping $name"
verify_b3_pid
kill ${pid}
if [ -n "${pid}" ]; then
wait_for_pids ${pid}
echo "Stopped"
fi
}
b3_status() {
verify_b3_pid && echo "$name is running as ${pid}" || echo "$name is not running"
}
run_rc_command "$1"
With this script you can stop/start/restart/ and check the status of big brother bot, ie is it running or not.
I have big brother bot installed at /home/b3/bigbrotherbot with an unprivileged user, b3, that runs my big brother bot.
I also created a directory under /var/log/b3 that is owned by b3 as I like to have my logs in one place. This ensures that the installation directory does not get clogged up with log files.
Other than that its pretty straight forward, hope this helps someone out as it drove me nuts for the past 2 days
