Skip to content

Commit 01e5504

Browse files
committed
Adding CodeDeploy files.
1 parent dbb5913 commit 01e5504

File tree

5 files changed

+50
-1
lines changed

5 files changed

+50
-1
lines changed

appspec.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 0.0
2+
os: linux
3+
files:
4+
- source: /target/nextwork-web-project.war
5+
destination: /usr/share/tomcat/webapps/
6+
hooks:
7+
BeforeInstall:
8+
- location: scripts/install_dependencies.sh
9+
timeout: 300
10+
runas: root
11+
ApplicationStart:
12+
- location: scripts/start_server.sh
13+
timeout: 300
14+
runas: root
15+
ApplicationStop:
16+
- location: scripts/stop_server.sh
17+
timeout: 300
18+
runas: root
19+

buildspec.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ phases:
2020
artifacts:
2121
files:
2222
- target/nextwork-web-project.war
23-
discard-paths: no
23+
- appspec.yml
24+
- scripts/**/*
25+
discard-paths: no

scripts/install_dependencies.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
sudo yum install tomcat -y
3+
sudo yum -y install httpd
4+
sudo cat << EOF > /etc/httpd/conf.d/tomcat_manager.conf
5+
<VirtualHost *:80>
6+
ServerAdmin root@localhost
7+
ServerName app.nextwork.com
8+
DefaultType text/html
9+
ProxyRequests off
10+
ProxyPreserveHost On
11+
ProxyPass / http://localhost:8080/nextwork-web-project/
12+
ProxyPassReverse / http://localhost:8080/nextwork-web-project/
13+
</VirtualHost>
14+
EOF

scripts/start_server.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
sudo systemctl start tomcat.service
3+
sudo systemctl enable tomcat.service
4+
sudo systemctl start httpd.service
5+
sudo systemctl enable httpd.service

scripts/stop_server.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
isExistApp="$(pgrep httpd)"
3+
if [[ -n $isExistApp ]]; then
4+
sudo systemctl stop httpd.service
5+
fi
6+
isExistApp="$(pgrep tomcat)"
7+
if [[ -n $isExistApp ]]; then
8+
sudo systemctl stop tomcat.service
9+
fi

0 commit comments

Comments
 (0)