Skip to content

Instantly share code, notes, and snippets.

@zhouyl
Created June 17, 2014 06:46
Show Gist options
  • Select an option

  • Save zhouyl/0078efc24b7c79ea8aa0 to your computer and use it in GitHub Desktop.

Select an option

Save zhouyl/0078efc24b7c79ea8aa0 to your computer and use it in GitHub Desktop.
Jekyll Service Helper
#!/bin/sh
ACTION="@$1"
if [ $ACTION = "@start" ] ; then
echo "Starting Jekyll Service..."
jekyll serve -w -B
PID=`ps -ef | grep "jekyll" | grep -v grep | awk '{print $2}'`
if [ $PID ] ; then
echo -e "Jekyll service startup succeed! \033[32;49;2m[YES]\033[39;49;0m"
else
echo -e "Jekyll service startup failed! \031[31;49;2m[NO]\033[39;49;0m"
fi
elif [ $ACTION = "@stop" ] ; then
echo -n "Stopping Jekyll Service..."
PID=`ps -ef | grep "jekyll" | grep -v grep | awk '{print $2}'`
if [ $PID ] ; then
kill -9 $PID
echo -e " \033[32;49;2m[YES]\033[39;49;0m"
else
echo -e " \033[31;49;2m[NO]\033[39;49;0m"
fi
elif [ $ACTION = '@restart' ] ; then
$0 stop
$0 start
else
echo "Usage: $0 [start|stop|restart]"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment