Created
March 16, 2020 18:08
-
-
Save hamzamu/569c73afb75d115236e3ab696ca30f23 to your computer and use it in GitHub Desktop.
Meteor deployment script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#============================ | |
# | |
# | |
# Meteor Deployment Script | |
# | |
# Require Installtion of pm2 | |
# | |
#============================ | |
Project_name= | |
BUILD_DIR=../../builds | |
SERVER= | |
USER= | |
ROOT_URL= | |
PORT=3001 | |
MONGO_URL='mongodb://localhost/meteor' | |
#============================ | |
echo "---------------------------------" | |
echo "Server Deployment for Meteor App: Check" | |
echo Project $Project_name | |
echo ROOT_URL: $ROOT_URL | |
echo PORT: $PORT | |
echo MONGO_URL: $MONGO_URL | |
FILE=$Project_name.tar.gz | |
echo "-----------------Building Starts----------------" | |
# meteor build $BUILD_DIR | |
echo "-----------------Building SUCCESS----------------" | |
#============================ | |
echo $(dirname "$PWD") | |
cd $BUILD_DIR | |
ls | |
#============================ | |
echo "Checking $Project_name.tar.gz" | |
if [ ! -f "$FILE" ]; then | |
echo "$FILE does not exist" | |
exit 1 | |
else | |
echo "$FILE exist" | |
fi | |
echo "Uploading file ======" | |
# scp $Project_name.tar.gz $USER@$SERVER:/home/nox | |
echo "===== File uploaded Success" | |
ssh -tt $USER@$SERVER << EOF | |
echo "---------------------------------" | |
echo "setting env parameters -- init" | |
echo "---------------------------------" | |
echo "Server Deployment for Meteor App: Exporting" | |
echo ROOT_URL: $ROOT_URL >> .bashrc | |
echo PORT: $PORT >> .bashrc | |
echo MONGO_URL: $MONGO_URL >> .bashrc | |
export PORT=$PORT | |
export MONGO_URL=$MONGO_URL | |
export ROOT_URL=$ROOT_URL | |
echo "setting env parameters -- done" | |
echo "--------------------------------- Export Complete" | |
exit 1 | |
pm2 delete 0 | |
cd /home/nox; bash | |
mv bundle bundle-old | |
ls; bash | |
# tar -zxvf outbreakmonitor.tar.gz -C h | |
tar -zxvf outbreakmonitor.tar.gz | |
echo "---------------------------------" | |
cd /home/nox/bundle/programs/server; bash | |
echo "---------------------------------" | |
echo "NPM: Install Packages" | |
npm i | |
echo "---------------------------------" | |
echo "cd /home/nox/bundle" | |
cd /home/nox/bundle; bash | |
echo "==========================" | |
echo Running pm2 | |
pm2 start main.js | |
echo "---------------SUCCESS------------------" | |
EOF | |
echo "---------------Deployment script success------------------" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment