-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-app-update.sh
More file actions
39 lines (31 loc) · 956 Bytes
/
Copy pathdeploy-app-update.sh
File metadata and controls
39 lines (31 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
appName=$1
appCommit=$2
uptime=30 # May need to adjust for apps with longer startup
cd $appName
source .env
forever stop keystone.js > /dev/null
git fetch
currentCommit=`git rev-parse HEAD` || unset currentCommit
git checkout -f $appCommit || {
echo "Checkout failed. Either the commit does not exist, or git is refusing to checkout for some other reason."
git checkout -f $currentCommit
forever --minUptime="${uptime}000" start keystone.js > /dev/null
exit 2
}
npm install --production 2>&1
forever --minUptime="${uptime}000" start keystone.js > /dev/null
sleep $uptime # Give keystone time to get up and running or fail
if nc -z $IP $PORT
then
echo "Running successfully"
exit 0
else # Travis should prevent this situation, but let's handle it anyway.
echo "Failed to start server:"
forever logs keystone.js
forever stop keystone.js > /dev/null # Just in case
exit 1
fi
# Exit codes:
# 0 - success
# 1 - failure
# 2 - can't checkout