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",
|
||||
"build": "run-p type-check \"build-only {@}\" -- && cp public/.htaccess dist/.htaccess",
|
||||
"preview": "vite preview",
|
||||
"start": "vite preview --port 4174 --host",
|
||||
"build-only": "vite build",
|
||||
"type-check": "vue-tsc --build",
|
||||
"lint": "eslint . --fix --cache",
|
||||
@@ -37,4 +38,4 @@
|
||||
"vite-plugin-vue-devtools": "^8.0.3",
|
||||
"vue-tsc": "^3.1.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ set -e
|
||||
|
||||
APP_NAME="tietokonepaja-fi"
|
||||
APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
DEPLOY_DIR="/var/www/tietokonepaja-fi"
|
||||
|
||||
echo "Deploying $APP_NAME from $APP_DIR..."
|
||||
|
||||
@@ -18,7 +17,13 @@ sudo bun install
|
||||
echo "Building application..."
|
||||
sudo bun run build
|
||||
|
||||
echo "Copying to $DEPLOY_DIR..."
|
||||
sudo cp -r dist/. "$DEPLOY_DIR"
|
||||
echo "Starting/reloading with pm2..."
|
||||
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."
|
||||
|
||||
Reference in New Issue
Block a user