lila/bin/prod/deploy
2013-10-10 10:25:30 +02:00

77 lines
1.3 KiB
Bash
Executable file

#!/bin/sh
. bin/lilarc
fail () {
echo "Deploy main or ai"
exit 1
}
mode=$1
if [ -z $mode ]; then
fail
elif [ $mode = "main" ]; then
REMOTE="hollie"
REMOTE_DIR="/home/lila5"
elif [ $mode = "ai" ]; then
REMOTE="paul"
REMOTE_DIR="/home/lila5"
elif [ $mode = "local" ]; then
REMOTE="localhost"
REMOTE_DIR="/tmp/lila5"
else
fail
fi
lilalog "Deploy to $mode server $REMOTE:$REMOTE_DIR"
if [ $mode != "local" ]; then
lilalog "Notify users of pre deploy"
bin/cli-prod deploy pre
fi
if [ $mode == "main" ]; then
bin/closure
fi
bin/play stage
if [ $? != 0 ]; then
lilalog "Deploy canceled"
exit 1
fi
RSYNC_OPTIONS=" \
--archive \
--force \
--delete \
--progress \
--compress \
--checksum \
--verbose \
--exclude conf/application.conf \
--exclude logs \
--exclude RUNNING_PID \
--exclude bin/.translate_version";
lilalog "Rsync scripts, binaries and assets"
stage="target/universal/stage"
rsync_command="rsync $RSYNC_OPTIONS bin $stage/bin $stage/lib public $REMOTE:$REMOTE_DIR"
echo "$rsync_command"
$rsync_command
if [ $mode != "local" ]; then
lilalog "Notify users of post deploy"
bin/cli-prod deploy post
fi
if [ $mode != "local" ]; then
lilalog "Restart lila5"
ssh $REMOTE "service lila5 restart"
fi
lilalog "Deploy complete"
if [ $mode != "local" ]; then
sleep 2
curl_prod
fi