Skip to content

Instantly share code, notes, and snippets.

@duanckham
Last active October 15, 2015 10:25
Show Gist options
  • Save duanckham/65d4c212006bab21fdf5 to your computer and use it in GitHub Desktop.
Save duanckham/65d4c212006bab21fdf5 to your computer and use it in GitHub Desktop.
#!/bin/sh
project_name=$1
project_path=/nodejs/$project_name
project_outlog=/var/log/xiaoyun/$project_name.log
project_errlog=/var/log/xiaoyun/$project_name.err
project_action=$2
project_start () {
echo "===================="
echo "* project : $project_path"
echo "* outlog : $project_outlog"
echo "* errlog : $project_errlog"
echo "===================="
forever --sourceDir $project_path -o $project_outlog -e $project_errlog start -c "npm start" .
}
project_stop () {
forever stop $project_path
pkill -f $project_path
}
project_restart () {
project_stop
project_start
}
project_log () {
tail -f $project_errlog $project_outlog
}
project_pull () {
cd $project_path
git pull
cd /
}
project_update () {
project_pull
project_restart
}
if test "$project_action" = "start"
then
project_start
fi
if test "$project_action" = "stop"
then
project_stop
fi
if test "$project_action" = "restart"
then
project_restart
fi
if test "$project_action" = "log"
then
project_log
fi
if test "$project_action" = "pull"
then
project_pull
fi
if test "$project_action" = "update"
then
project_update
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment