Skip to content

Instantly share code, notes, and snippets.

@janlelis
Created December 21, 2013 19:35
Show Gist options
  • Save janlelis/8073892 to your computer and use it in GitHub Desktop.
Save janlelis/8073892 to your computer and use it in GitHub Desktop.
A simple init script for the palava-machine. Put it in /etc/init.d/ and make it executable.
#!/bin/bash
invoke()
{
echo "[$1]"
su - palava -c "ruby -S palava-machine-daemon $1"
}
start_multiple()
{
if [ "$1" ]
then
n=$1;
else
n=1;
fi
for (( c=1; c<=n; c++ ))
do
invoke start
done
}
case "$1" in
start)
start_multiple "$2"
;;
stop)
invoke stop
;;
*)
echo "Usage: service palava-machine {start|stop} [number of instances if start]" >&2
exit 3
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment