Last active
October 26, 2018 11:29
-
-
Save johnchidgey/88ef5bcd1f4d1da6edcea2b0ed2ae2a5 to your computer and use it in GitHub Desktop.
Centos 6 INIT Script for Pleroma
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/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