Instantly share code, notes, and snippets.

@johnchidgey /pleroma
Last active Oct 26, 2018

Embed
What would you like to do?
Centos 6 INIT Script for Pleroma
#!/bin/bash
#
# Pleroma Server
#
# chkconfig: 345 70 30
# description: Pleroma Server is a better Mastodon
# processname: pleroma
# Source function library.
. /etc/init.d/functions
RETVAL=0
prog="pleroma"
LOCKFILE=/var/lock/subsys/$prog
start() {
echo -n "Starting $prog: "
sudo -u pleroma sh -c 'cd /home/pleroma/pleroma && MIX_ENV=prod /usr/local/bin/elixir --detached -S /usr/local/bin/mix phx.server'
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCKFILE
echo
return $RETVAL
}
stop() {
echo -n "Shutting down $prog: "
PID=`ps -ef | grep elixir | grep -v "grep" | awk '{print $2}'`
echo $PID
kill -9 $PID
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
echo
return $RETVAL
}
status() {
echo -n "Checking $prog status: "
# PID=`ps -ef | grep elixir | grep -v "grep" | awk '{print $2}'`
if (( $(ps -ef | grep -v grep | grep elixir | wc -l) > 0 ))
then
echo -n "Running"
else
echo -n "Stopped"
fi
echo
return
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
*)
echo "Usage: $prog {start|stop|status|restart}"
exit 1
;;
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment