fix: use dedicated PM2 process name karate_halloween on port 34822
This commit is contained in:
1 parent
1b3562f03c
commit
fc5d96e72c
3 files changed
+22
-21
No files matched your search
@@ -3,40 +3,40 @@
|
|||||||
Target Host / Domain: **`karate.ph.sokaris.link`**
|
Target Host / Domain: **`karate.ph.sokaris.link`**
|
||||||
Web Server: **Nginx**
|
Web Server: **Nginx**
|
||||||
Execution User: **`www-data`**
|
Execution User: **`www-data`**
|
||||||
Port: **`34821`**
|
Port: **`34822`**
|
||||||
Git Repository: **`https://dep.sokaris.link/vasily/karate_halloween.git`**
|
Git Repository: **`https://dep.sokaris.link/vasily/karate_halloween.git`**
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 1. Directory Structure & Permissions
|
## 1. Directory Structure & Permissions
|
||||||
|
|
||||||
Recommended app directory on the server: `/var/www/karate_halloween`
|
Recommended app directory on the server: `/srv/apps/karate_halloween`
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Create directory and clone repository (or set ownership)
|
# Create directory and clone repository (or set ownership)
|
||||||
sudo mkdir -p /var/www/karate_halloween
|
sudo mkdir -p /srv/apps/karate_halloween
|
||||||
sudo git clone https://dep.sokaris.link/vasily/karate_halloween.git /var/www/karate_halloween
|
sudo git clone https://dep.sokaris.link/vasily/karate_halloween.git /srv/apps/karate_halloween
|
||||||
|
|
||||||
# Ensure ownership belongs to www-data
|
# Ensure ownership belongs to www-data
|
||||||
sudo chown -R www-data:www-data /var/www/karate_halloween
|
sudo chown -R www-data:www-data /srv/apps/karate_halloween
|
||||||
sudo chmod -R 775 /var/www/karate_halloween
|
sudo chmod -R 775 /srv/apps/karate_halloween
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 2. Environment Variables Configuration
|
## 2. Environment Variables Configuration
|
||||||
|
|
||||||
Create `/var/www/karate_halloween/.env.local`:
|
Create `/srv/apps/karate_halloween/.env.local`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo -u www-data nano /var/www/karate_halloween/.env.local
|
sudo -u www-data nano /srv/apps/karate_halloween/.env.local
|
||||||
```
|
```
|
||||||
|
|
||||||
Example content:
|
Example content:
|
||||||
```env
|
```env
|
||||||
# Production Environment
|
# Production Environment
|
||||||
NODE_ENV=production
|
NODE_ENV=production
|
||||||
PORT=34821
|
PORT=34822
|
||||||
|
|
||||||
# AI API Keys
|
# AI API Keys
|
||||||
GEMINI_API_KEY=your_gemini_api_key_here
|
GEMINI_API_KEY=your_gemini_api_key_here
|
||||||
@@ -51,7 +51,7 @@ GENERATION_MODEL=nanobanana 2
|
|||||||
Run as `www-data`:
|
Run as `www-data`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd /var/www/karate_halloween
|
cd /srv/apps/karate_halloween
|
||||||
sudo -u www-data npm ci
|
sudo -u www-data npm ci
|
||||||
sudo -u www-data npm run build
|
sudo -u www-data npm run build
|
||||||
```
|
```
|
||||||
@@ -68,7 +68,7 @@ sudo npm install -g pm2
|
|||||||
### Start the application with PM2 as `www-data`:
|
### Start the application with PM2 as `www-data`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo -u www-data pm2 start /var/www/karate_halloween/ecosystem.config.cjs
|
sudo -u www-data pm2 start /srv/apps/karate_halloween/ecosystem.config.cjs
|
||||||
sudo -u www-data pm2 save
|
sudo -u www-data pm2 save
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -87,13 +87,13 @@ sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -
|
|||||||
sudo -u www-data pm2 status
|
sudo -u www-data pm2 status
|
||||||
|
|
||||||
# View live logs
|
# View live logs
|
||||||
sudo -u www-data pm2 logs photobooth_web_v1
|
sudo -u www-data pm2 logs karate_halloween
|
||||||
|
|
||||||
# Reload zero-downtime
|
# Reload zero-downtime
|
||||||
sudo -u www-data pm2 reload photobooth_web_v1
|
sudo -u www-data pm2 reload karate_halloween
|
||||||
|
|
||||||
# Restart
|
# Restart
|
||||||
sudo -u www-data pm2 restart photobooth_web_v1
|
sudo -u www-data pm2 restart karate_halloween
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -103,7 +103,7 @@ sudo -u www-data pm2 restart photobooth_web_v1
|
|||||||
Copy the provided Nginx configuration to `sites-available`:
|
Copy the provided Nginx configuration to `sites-available`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo cp /var/www/karate_halloween/deploy/karate.ph.sokaris.link.conf /etc/nginx/sites-available/karate.ph.sokaris.link.conf
|
sudo cp /srv/apps/karate_halloween/deploy/karate.ph.sokaris.link.conf /etc/nginx/sites-available/karate.ph.sokaris.link.conf
|
||||||
sudo ln -sf /etc/nginx/sites-available/karate.ph.sokaris.link.conf /etc/nginx/sites-enabled/
|
sudo ln -sf /etc/nginx/sites-available/karate.ph.sokaris.link.conf /etc/nginx/sites-enabled/
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -127,5 +127,5 @@ sudo systemctl reload nginx
|
|||||||
Whenever you push new updates to git, deploy on the server with:
|
Whenever you push new updates to git, deploy on the server with:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo -u www-data bash /var/www/karate_halloween/deploy/deploy.sh
|
sudo -u www-data bash /srv/apps/karate_halloween/deploy/deploy.sh
|
||||||
```
|
```
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# Production Nginx reverse proxy configuration for Karate Halloween Photo Booth
|
# Production Nginx reverse proxy configuration for Karate Halloween Photo Booth
|
||||||
# Domain: karate.ph.sokaris.link
|
# Domain: karate.ph.sokaris.link
|
||||||
# Backend: Next.js PM2 process on 127.0.0.1:34821
|
# Backend: Next.js PM2 process on 127.0.0.1:34822
|
||||||
# User: www-data
|
# User: www-data
|
||||||
|
|
||||||
# Rate limiting zones (can be defined in http block in /etc/nginx/nginx.conf or here if http-level included)
|
# Rate limiting zones (can be defined in http block in /etc/nginx/nginx.conf or here if http-level included)
|
||||||
@@ -10,7 +10,7 @@ limit_req_zone $binary_remote_addr zone=karate_api_limit:10m rate=10r/s;
|
|||||||
limit_req_zone $binary_remote_addr zone=karate_auth_limit:10m rate=5r/m;
|
limit_req_zone $binary_remote_addr zone=karate_auth_limit:10m rate=5r/m;
|
||||||
|
|
||||||
upstream karate_backend {
|
upstream karate_backend {
|
||||||
server 127.0.0.1:34821;
|
server 127.0.0.1:34822;
|
||||||
keepalive 32;
|
keepalive 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
apps: [
|
apps: [
|
||||||
{
|
{
|
||||||
name: "photobooth_web_v1",
|
name: "karate_halloween",
|
||||||
script: "node_modules/next/dist/bin/next",
|
script: "node_modules/next/dist/bin/next",
|
||||||
args: "start -p 34821",
|
args: "start -p 34822 -H 127.0.0.1",
|
||||||
cwd: __dirname,
|
cwd: __dirname,
|
||||||
instances: 1,
|
instances: 1,
|
||||||
autorestart: true,
|
autorestart: true,
|
||||||
@@ -12,7 +12,8 @@ module.exports = {
|
|||||||
interpreter: "node",
|
interpreter: "node",
|
||||||
env: {
|
env: {
|
||||||
NODE_ENV: "production",
|
NODE_ENV: "production",
|
||||||
PORT: 34821,
|
PORT: 34822,
|
||||||
|
HOSTNAME: "127.0.0.1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in new issue
Block a user