#!/bin/sh CWD=$(pwd) SERVER='bundle exec rackup' SERVER_OPTIONS=' -D -P ./ledgerrb.pid' function start() { $SERVER $SERVER_OPTIONS } function stop() { [ -e ./ledgerrb.pid ] && kill $(cat ./ledgerrb.pid) } function restart() { stop && sleep 3 && start } case $1 in "start") start ;; "stop") stop ;; "restart") restart ;; *) echo "Usage; start|stop|restart" ;; esac