From 6fdb294399f47488ce70079a27b86cbf59092373 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Tuan Date: Sat, 17 Aug 2024 16:05:57 +0700 Subject: [PATCH] Update update script --- backend/install.sh | 14 +++++++++++++- backend/nodejs/scripts/install.sh | 11 ++++------- backend/nodejs/scripts/start.sh | 9 +++++++++ backend/python/scripts/install.sh | 4 ++-- 4 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 backend/nodejs/scripts/start.sh diff --git a/backend/install.sh b/backend/install.sh index 39d832c..e58c3d9 100644 --- a/backend/install.sh +++ b/backend/install.sh @@ -1,7 +1,19 @@ #!/bin/bash +# Change directory to `backend` +cd /home/backend + # Install NodeJS Server bash nodejs/scripts/install.sh +# Change directory to `backend` +cd /home/backend + # Install Python -bash python/scripts/install.sh \ No newline at end of file +bash python/scripts/install.sh + +# Change directory to `backend` +cd /home/backend + +# Start server +bash nodejs/scripts/start.sh \ No newline at end of file diff --git a/backend/nodejs/scripts/install.sh b/backend/nodejs/scripts/install.sh index 4af8b9e..e5f7d41 100644 --- a/backend/nodejs/scripts/install.sh +++ b/backend/nodejs/scripts/install.sh @@ -19,16 +19,13 @@ printf "NVM has just been installed: $(nvm -v)" ### Install node 20 nvm install node 20 +### Change directory to `nodejs` +cd /home/backend/nodejs + ### Check version of `node` and `npm` printf "Node has just been installed: $(node -v)" printf "NPM has just been installed: $(npm -v)" ## Install packages in `package.json` npm install -npm install -g pm2 - -## Start server -npm start - -## Enable log -pm2 logs \ No newline at end of file +npm install -g pm2 \ No newline at end of file diff --git a/backend/nodejs/scripts/start.sh b/backend/nodejs/scripts/start.sh new file mode 100644 index 0000000..f2c7ce8 --- /dev/null +++ b/backend/nodejs/scripts/start.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# Change directory to `nodejs` +cd /home/backend/nodejs + +# Start NodeJS Server +npm start + +pm2 logs \ No newline at end of file diff --git a/backend/python/scripts/install.sh b/backend/python/scripts/install.sh index 4150ed7..df105e9 100644 --- a/backend/python/scripts/install.sh +++ b/backend/python/scripts/install.sh @@ -15,8 +15,8 @@ printf "Python has been just installed: $(python3 --version)" apt install python3-pip printf "PIP has just been installed: $(node -v)" -## Move to `python` -cd ../ +# Change directory to `backend` +cd /home/backend/python ## Install packages in `requirements.txt` pip3 install -r requirements.txt