Add PM2 setup to deployment script
Add a start script using vite preview on port 4174 and replace the static file copy step in deploy.sh with PM2 start/reload logic.
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "run-p type-check \"build-only {@}\" -- && cp public/.htaccess dist/.htaccess",
|
"build": "run-p type-check \"build-only {@}\" -- && cp public/.htaccess dist/.htaccess",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
|
"start": "vite preview --port 4174 --host",
|
||||||
"build-only": "vite build",
|
"build-only": "vite build",
|
||||||
"type-check": "vue-tsc --build",
|
"type-check": "vue-tsc --build",
|
||||||
"lint": "eslint . --fix --cache",
|
"lint": "eslint . --fix --cache",
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ set -e
|
|||||||
|
|
||||||
APP_NAME="tietokonepaja-fi"
|
APP_NAME="tietokonepaja-fi"
|
||||||
APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
DEPLOY_DIR="/var/www/tietokonepaja-fi"
|
|
||||||
|
|
||||||
echo "Deploying $APP_NAME from $APP_DIR..."
|
echo "Deploying $APP_NAME from $APP_DIR..."
|
||||||
|
|
||||||
@@ -18,7 +17,13 @@ sudo bun install
|
|||||||
echo "Building application..."
|
echo "Building application..."
|
||||||
sudo bun run build
|
sudo bun run build
|
||||||
|
|
||||||
echo "Copying to $DEPLOY_DIR..."
|
echo "Starting/reloading with pm2..."
|
||||||
sudo cp -r dist/. "$DEPLOY_DIR"
|
if pm2 describe "$APP_NAME" > /dev/null 2>&1; then
|
||||||
|
pm2 reload "$APP_NAME" --update-env
|
||||||
|
else
|
||||||
|
pm2 start bun --name "$APP_NAME" -- run start
|
||||||
|
fi
|
||||||
|
|
||||||
|
pm2 save
|
||||||
|
|
||||||
echo "Deployment complete."
|
echo "Deployment complete."
|
||||||
|
|||||||
Reference in New Issue
Block a user