-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·65 lines (53 loc) · 1.27 KB
/
deploy.sh
File metadata and controls
executable file
·65 lines (53 loc) · 1.27 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# code-drills deployment script
# This script DOES not pulls the git repo. It only packages, copies and deploys
# function to check success of last command
check() {
if [ $? -eq 0 ]; then
echo
echo "$1 successful"
echo
else
echo
echo "$1 failed!"
echo
exit -1
fi
}
# Display branch
branch=`git symbolic-ref --short HEAD`
echo "Deploying branch $branch"
sleep 2
# compile and create a package with prod profile
mvn clean package
check "Packaging"
# tag with current time stamp
echo "Pushing tag"
tagname=prod-$(date +%Y%m%d.%H%M%S)
git tag -a $tagname -m "Deployment script"
check "Tag"
#git push origin $tagname
#check "Push tag"
# copy the created jar file
sudo cp target/code-drills.jar /var/code-drills/
check "Copying jar"
# stop currently running service
sudo /etc/init.d/code-drills stop
check "Stopping service"
# start newly copied service
sudo /etc/init.d/code-drills start
check "Starting service"
# sleep a bit
echo "Sleeping for 60 seconds"
sleep 60
check "Sleeping"
# ping the site
echo "pinging for status"
response=`curl https://recommender.codedrills.io/status`
if [ "$response" != "OK" ]; then
echo "Status not OK"
exit -1
fi
echo
# done!
echo "code-drills succesfully deployed"