Skip to content

Commit

Permalink
add ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
sdvdxl committed Jun 11, 2017
1 parent e4d834f commit 28a1300
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@

.history
vendor
cfg.json
cfg.json
var
message.zip
falcon-message
127 changes: 127 additions & 0 deletions control
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@

#!/bin/bash

WORKSPACE=$(cd $(dirname $0)/; pwd)
cd $WORKSPACE

mkdir -p var

module=message
app=falcon-$module
conf=cfg.json
pidfile=var/app.pid
logfile=var/app.log

function check_pid() {
if [ -f $pidfile ];then
pid=`cat $pidfile`
if [ -n $pid ]; then
running=`ps -p $pid|grep -v "PID TTY" |wc -l`
return $running
fi
fi
return 0
}

function start() {
check_pid
running=$?
if [ $running -gt 0 ];then
echo -n "$app now is running already, pid="
cat $pidfile
return 1
fi

if ! [ -f $conf ];then
echo "Config file $conf doesn't exist, creating one."
cp cfg.example.json $conf
fi
nohup ./$app -c $conf &> $logfile &
sleep 1
running=`ps -p $! | grep -v "PID TTY" | wc -l`
if [ $running -gt 0 ];then
echo $! > $pidfile
echo "$app started..., pid=$!"
else
echo "$app failed to start."
return 1
fi
}

function stop() {
pid=`cat $pidfile`
kill $pid
rm -f $pidfile
echo "$app stoped..."
}

function restart() {
stop
sleep 1
start
}

function status() {
check_pid
running=$?
if [ $running -gt 0 ];then
echo started
else
echo stoped
fi
}

function tailf() {
tail -f $logfile
}

function build() {
go build
if [ $? -ne 0 ]; then
exit $?
fi
mv $module $app
./$app -v
}

function pack() {
build
git log -1 --pretty=%h > gitversion
version=`./$app -v`
file_list="public control cfg.example.json $app"
echo "...tar $app-$version.tar.gz <= $file_list"
tar zcf $app-$version.tar.gz gitversion $file_list
}

function packbin() {
build
git log -1 --pretty=%h > gitversion
version=`./$app -v`
tar zcvf $app-bin-$version.tar.gz $app gitversion
}

function help() {
echo "$0 build|pack|start|stop|restart|status|tail"
}

if [ "$1" == "" ]; then
help
elif [ "$1" == "stop" ];then
stop
elif [ "$1" == "start" ];then
start
elif [ "$1" == "restart" ];then
restart
elif [ "$1" == "status" ];then
status
elif [ "$1" == "tail" ];then
tailf
elif [ "$1" == "build" ];then
build
elif [ "$1" == "pack" ];then
pack
elif [ "$1" == "packbin" ];then
packbin
else
help
fi
Binary file removed falcon-message
Binary file not shown.
2 changes: 1 addition & 1 deletion glide.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package: github.com/sdvdxl/falcon-message
import:
- package: github.com/labstack/echo
version: v3.1.0
version: ~3.1.0
subpackages:
- middleware
- package: github.com/tylerb/graceful
Expand Down

0 comments on commit 28a1300

Please sign in to comment.