Skip to content
This repository was archived by the owner on Sep 25, 2025. It is now read-only.

Commit 24d1bd3

Browse files
committed
updated
1 parent 863d654 commit 24d1bd3

File tree

7 files changed

+43
-8
lines changed

7 files changed

+43
-8
lines changed

appspec.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
version: 0.0
22
os: linux
33
files:
4-
- source: /
4+
- source: .
55
destination: /home/ubuntu/app
6+
67
hooks:
8+
ApplicationStop:
9+
- location: scripts/stop_server.sh
10+
timeout: 60
11+
runas: ubuntu
12+
13+
BeforeInstall:
14+
- location: scripts/before_install.sh
15+
timeout: 60
16+
runas: ubuntu
17+
718
AfterInstall:
8-
- location: scripts/install.sh
9-
timeout: 30
19+
- location: scripts/install_dependencies.sh
20+
timeout: 60
1021
runas: ubuntu
22+
1123
ApplicationStart:
12-
- location: scripts/start.sh
13-
timeout: 30
24+
- location: scripts/start_server.sh
25+
timeout: 60
1426
runas: ubuntu

ecosystem.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
apps: [
3+
{
4+
name: 'app',
5+
script: './index.js',
6+
instances: 1,
7+
autorestart: true,
8+
watch: false,
9+
max_memory_restart: '200M',
10+
env: {
11+
NODE_ENV: 'production',
12+
},
13+
},
14+
],
15+
}

scripts/before_install.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
echo "Cleaning old app files..."
3+
rm -rf /home/ubuntu/app/*
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/bash
2+
echo "Installing dependencies..."
23
cd /home/ubuntu/app
34
npm install

scripts/start.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

scripts/start_server.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
echo "Starting the app with PM2..."
3+
cd /home/ubuntu/app
4+
pm2 start ecosystem.config.js

scripts/stop_server.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
echo "Stopping existing app..."
3+
pm2 stop ecosystem.config.js || true

0 commit comments

Comments
 (0)