@gv-sh/specgen-app 0.6.7 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -24
- package/package.json +1 -1
- package/scripts/deploy.sh +54 -32
- package/scripts/production.sh +16 -16
- package/scripts/setup.sh +14 -14
- package/scripts/deploy-8080.sh.bak +0 -104
- package/scripts/production-low-memory.sh.bak +0 -129
- package/scripts/setup-low-memory.sh.bak +0 -203
package/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# SpecGen App - Complete Platform
|
2
2
|
|
3
|
-
[](https://github.com/gv-sh/specgen-app)
|
4
4
|
|
5
|
-
A unified deployment package for the SpecGen speculative fiction generator platform. **Optimized for port
|
5
|
+
A unified deployment package for the SpecGen speculative fiction generator platform. **Optimized for port 80 deployment with low memory usage.**
|
6
6
|
|
7
7
|
## 🚀 Quick Start
|
8
8
|
|
@@ -19,7 +19,7 @@ npx @gv-sh/specgen-app deploy
|
|
19
19
|
**What this does:**
|
20
20
|
- Downloads and sets up server, admin, and user components
|
21
21
|
- Builds React frontends optimized for production
|
22
|
-
- Configures everything for port
|
22
|
+
- Configures everything for port 80
|
23
23
|
- Starts with PM2 for process management
|
24
24
|
- Prompts for OpenAI API key
|
25
25
|
|
@@ -27,12 +27,12 @@ npx @gv-sh/specgen-app deploy
|
|
27
27
|
|
28
28
|
Once deployed, access your application at:
|
29
29
|
|
30
|
-
- **Main Application**: http://your-server:
|
31
|
-
- **User Interface**: http://your-server:
|
32
|
-
- **Admin Panel**: http://your-server:
|
33
|
-
- **API Documentation**: http://your-server:
|
34
|
-
- **Health Check**: http://your-server:
|
35
|
-
- **API Endpoints**: http://your-server:
|
30
|
+
- **Main Application**: http://your-server:80/
|
31
|
+
- **User Interface**: http://your-server:80/app
|
32
|
+
- **Admin Panel**: http://your-server:80/admin
|
33
|
+
- **API Documentation**: http://your-server:80/api-docs
|
34
|
+
- **Health Check**: http://your-server:80/api/health
|
35
|
+
- **API Endpoints**: http://your-server:80/api/*
|
36
36
|
|
37
37
|
## 🖥️ Server Requirements
|
38
38
|
|
@@ -80,7 +80,7 @@ npx @gv-sh/specgen-app dev
|
|
80
80
|
**Development URLs:**
|
81
81
|
- User Interface: http://localhost:3002
|
82
82
|
- Admin Interface: http://localhost:3001
|
83
|
-
- API Server: http://localhost:
|
83
|
+
- API Server: http://localhost:80
|
84
84
|
|
85
85
|
### Method 3: Manual Deployment
|
86
86
|
|
@@ -106,7 +106,7 @@ During deployment, you'll be prompted for your OpenAI API key. You can also set
|
|
106
106
|
# Create/edit the environment file
|
107
107
|
echo "OPENAI_API_KEY=your_openai_api_key_here" > server/.env
|
108
108
|
echo "NODE_ENV=production" >> server/.env
|
109
|
-
echo "PORT=
|
109
|
+
echo "PORT=80" >> server/.env
|
110
110
|
|
111
111
|
# Restart the service
|
112
112
|
npx pm2 restart specgen --update-env
|
@@ -115,7 +115,7 @@ npx pm2 restart specgen --update-env
|
|
115
115
|
### Environment Variables
|
116
116
|
|
117
117
|
The deployment creates these configuration files:
|
118
|
-
- `server/.env` - Server configuration (port
|
118
|
+
- `server/.env` - Server configuration (port 80, API key)
|
119
119
|
- `admin/.env.development` - Admin development settings
|
120
120
|
- `user/.env.development` - User development settings
|
121
121
|
|
@@ -144,13 +144,13 @@ npx pm2 monit
|
|
144
144
|
|
145
145
|
### Common Issues and Solutions
|
146
146
|
|
147
|
-
#### 1. Port
|
147
|
+
#### 1. Port 80 Already in Use
|
148
148
|
```bash
|
149
149
|
# Check what's using the port
|
150
|
-
sudo lsof -i :
|
150
|
+
sudo lsof -i :80
|
151
151
|
|
152
152
|
# Kill the process
|
153
|
-
sudo lsof -ti:
|
153
|
+
sudo lsof -ti:80 | xargs kill -9
|
154
154
|
|
155
155
|
# Redeploy
|
156
156
|
npx @gv-sh/specgen-app deploy
|
@@ -178,7 +178,7 @@ npx pm2 env 0
|
|
178
178
|
# Update API key
|
179
179
|
echo "OPENAI_API_KEY=your_new_key_here" > server/.env
|
180
180
|
echo "NODE_ENV=production" >> server/.env
|
181
|
-
echo "PORT=
|
181
|
+
echo "PORT=80" >> server/.env
|
182
182
|
|
183
183
|
# Restart with new environment
|
184
184
|
npx pm2 restart specgen --update-env
|
@@ -211,10 +211,10 @@ sudo apt-get install -y nodejs
|
|
211
211
|
|
212
212
|
```bash
|
213
213
|
# Test API health
|
214
|
-
curl http://localhost:
|
214
|
+
curl http://localhost:80/api/health
|
215
215
|
|
216
216
|
# Test main page response
|
217
|
-
curl -I http://localhost:
|
217
|
+
curl -I http://localhost:80/
|
218
218
|
|
219
219
|
# Check server logs
|
220
220
|
npx pm2 logs specgen --lines 50
|
@@ -222,8 +222,8 @@ npx pm2 logs specgen --lines 50
|
|
222
222
|
# Check build status
|
223
223
|
ls -la */build/ 2>/dev/null || echo "No builds found"
|
224
224
|
|
225
|
-
# Check processes listening on port
|
226
|
-
sudo netstat -tlnp | grep :
|
225
|
+
# Check processes listening on port 80
|
226
|
+
sudo netstat -tlnp | grep :80
|
227
227
|
```
|
228
228
|
|
229
229
|
### Manual Build Process
|
@@ -265,14 +265,14 @@ npx pm2 start server/index.js --name specgen
|
|
265
265
|
- **Static File Serving**: Builds must complete successfully for frontend access
|
266
266
|
|
267
267
|
### AWS EC2 Specific
|
268
|
-
- **Security Groups**: Ensure port
|
268
|
+
- **Security Groups**: Ensure port 80 is open in your security group
|
269
269
|
- **Instance Type**: t2.micro may struggle with builds (t2.small recommended)
|
270
270
|
- **Storage**: Ensure at least 2GB free space for node_modules and builds
|
271
271
|
|
272
272
|
## 📚 API Documentation
|
273
273
|
|
274
274
|
Once deployed, access interactive API documentation at:
|
275
|
-
- **Swagger UI**: http://your-server:
|
275
|
+
- **Swagger UI**: http://your-server:80/api-docs
|
276
276
|
|
277
277
|
### Key API Endpoints
|
278
278
|
- `GET /api/health` - Health check and system status
|
@@ -303,7 +303,7 @@ tar -czf specgen-backup-$(date +%Y%m%d).tar.gz server/data server/.env logs/
|
|
303
303
|
## 🤝 Support
|
304
304
|
|
305
305
|
### Getting Help
|
306
|
-
- **Health Check**: Visit http://your-server:
|
306
|
+
- **Health Check**: Visit http://your-server:80/api/health
|
307
307
|
- **Logs**: Run `npx pm2 logs specgen`
|
308
308
|
- **Issues**: [GitHub Issues](https://github.com/gv-sh/specgen-app/issues)
|
309
309
|
- **Status**: Run `npx pm2 status` to check process status
|
@@ -311,7 +311,7 @@ tar -czf specgen-backup-$(date +%Y%m%d).tar.gz server/data server/.env logs/
|
|
311
311
|
### Reporting Bugs
|
312
312
|
When reporting issues, please include:
|
313
313
|
- Output of `npx pm2 logs specgen`
|
314
|
-
- Output of `curl http://localhost:
|
314
|
+
- Output of `curl http://localhost:80/api/health`
|
315
315
|
- Your server specifications (RAM, OS version, Node.js version)
|
316
316
|
- Any error messages from the deployment process
|
317
317
|
|
package/package.json
CHANGED
package/scripts/deploy.sh
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
|
3
|
-
# SpecGen Deploy Script - Self-Contained Deployment on Port
|
3
|
+
# SpecGen Deploy Script - Self-Contained Deployment on Port 80
|
4
4
|
set -e
|
5
5
|
|
6
6
|
# Check for dry-run mode
|
@@ -10,7 +10,7 @@ if [ "$1" = "--dry-run" ] || [ "$1" = "-d" ]; then
|
|
10
10
|
echo "🧪 DRY RUN MODE - Testing deployment locally"
|
11
11
|
echo "🖥️ Platform: $(uname -s) $(uname -m)"
|
12
12
|
else
|
13
|
-
echo "🚀 Deploying SpecGen to production on port
|
13
|
+
echo "🚀 Deploying SpecGen to production on port 80..."
|
14
14
|
echo "📦 This is a complete deployment - no separate setup needed!"
|
15
15
|
fi
|
16
16
|
|
@@ -66,7 +66,7 @@ if [ "$DRY_RUN" = false ]; then
|
|
66
66
|
rm -f ecosystem.config.js 2>/dev/null || true
|
67
67
|
|
68
68
|
# Kill processes on all relevant ports
|
69
|
-
for port in
|
69
|
+
for port in 80 3000 3001 3002; do
|
70
70
|
if ! check_port $port; then
|
71
71
|
echo "Killing processes on port $port..."
|
72
72
|
lsof -ti:$port | xargs kill -9 2>/dev/null || true
|
@@ -117,7 +117,7 @@ if [ "$DRY_RUN" = true ]; then
|
|
117
117
|
mkdir -p "$PROJECT_DIR/server"
|
118
118
|
echo "OPENAI_API_KEY=sk-test1234567890abcdef" > "$PROJECT_DIR/server/.env"
|
119
119
|
echo "NODE_ENV=production" >> "$PROJECT_DIR/server/.env"
|
120
|
-
echo "PORT=
|
120
|
+
echo "PORT=80" >> "$PROJECT_DIR/server/.env"
|
121
121
|
echo "HOST=$BIND_HOST" >> "$PROJECT_DIR/server/.env"
|
122
122
|
elif [ ! -f "$PROJECT_DIR/server/.env" ] || grep -q "your_openai_api_key_here" "$PROJECT_DIR/server/.env" 2>/dev/null; then
|
123
123
|
if [ "$CI" = "true" ]; then
|
@@ -125,7 +125,7 @@ elif [ ! -f "$PROJECT_DIR/server/.env" ] || grep -q "your_openai_api_key_here" "
|
|
125
125
|
mkdir -p "$PROJECT_DIR/server"
|
126
126
|
echo "OPENAI_API_KEY=sk-test1234" > "$PROJECT_DIR/server/.env"
|
127
127
|
echo "NODE_ENV=production" >> "$PROJECT_DIR/server/.env"
|
128
|
-
echo "PORT=
|
128
|
+
echo "PORT=80" >> "$PROJECT_DIR/server/.env"
|
129
129
|
echo "HOST=$BIND_HOST" >> "$PROJECT_DIR/server/.env"
|
130
130
|
else
|
131
131
|
echo "⚠️ OpenAI API key required for SpecGen to work."
|
@@ -140,7 +140,7 @@ elif [ ! -f "$PROJECT_DIR/server/.env" ] || grep -q "your_openai_api_key_here" "
|
|
140
140
|
mkdir -p "$PROJECT_DIR/server"
|
141
141
|
echo "OPENAI_API_KEY=$OPENAI_KEY" > "$PROJECT_DIR/server/.env"
|
142
142
|
echo "NODE_ENV=production" >> "$PROJECT_DIR/server/.env"
|
143
|
-
echo "PORT=
|
143
|
+
echo "PORT=80" >> "$PROJECT_DIR/server/.env"
|
144
144
|
echo "HOST=$BIND_HOST" >> "$PROJECT_DIR/server/.env"
|
145
145
|
echo "✅ API key saved"
|
146
146
|
fi
|
@@ -178,7 +178,7 @@ if [ ! -f "server/index.js" ]; then
|
|
178
178
|
# Install unified server that binds to 0.0.0.0
|
179
179
|
echo " 🔧 Installing unified server (binds to all interfaces)..."
|
180
180
|
cat > server/index.js << 'EOF'
|
181
|
-
// index.js - Unified server for port
|
181
|
+
// index.js - Unified server for port 80 with public binding
|
182
182
|
/* global process */
|
183
183
|
require('dotenv').config();
|
184
184
|
const express = require('express');
|
@@ -188,7 +188,7 @@ const errorHandler = require('./middleware/errorHandler');
|
|
188
188
|
|
189
189
|
// Initialize Express app
|
190
190
|
const app = express();
|
191
|
-
const PORT = process.env.PORT ||
|
191
|
+
const PORT = process.env.PORT || 80;
|
192
192
|
const HOST = process.env.HOST || '0.0.0.0'; // Bind to all interfaces by default
|
193
193
|
|
194
194
|
// Middleware
|
@@ -350,6 +350,8 @@ for component in admin user; do
|
|
350
350
|
fi
|
351
351
|
done
|
352
352
|
|
353
|
+
npm install --no-save serve
|
354
|
+
|
353
355
|
# ========================================
|
354
356
|
# VERIFY BUILDS
|
355
357
|
# ========================================
|
@@ -371,7 +373,7 @@ if [ "$DRY_RUN" = true ]; then
|
|
371
373
|
cd "$PROJECT_DIR"
|
372
374
|
cp server/.env .env 2>/dev/null || true
|
373
375
|
|
374
|
-
TEST_PORT=
|
376
|
+
TEST_PORT=80
|
375
377
|
if ! check_port $TEST_PORT; then
|
376
378
|
TEST_PORT=8081
|
377
379
|
fi
|
@@ -401,36 +403,56 @@ else
|
|
401
403
|
|
402
404
|
cat > "$PROJECT_DIR/ecosystem.config.js" << EOF
|
403
405
|
module.exports = {
|
404
|
-
apps: [
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
406
|
+
apps: [
|
407
|
+
{
|
408
|
+
name: 'specgen',
|
409
|
+
script: '$PROJECT_DIR/server/index.js',
|
410
|
+
cwd: '$PROJECT_DIR',
|
411
|
+
env: {
|
412
|
+
NODE_ENV: 'production',
|
413
|
+
PORT: 80,
|
414
|
+
HOST: '$BIND_HOST'
|
415
|
+
},
|
416
|
+
instances: 1,
|
417
|
+
exec_mode: 'fork',
|
418
|
+
max_memory_restart: '500M',
|
419
|
+
error_file: '$PROJECT_DIR/logs/err.log',
|
420
|
+
out_file: '$PROJECT_DIR/logs/out.log',
|
421
|
+
log_file: '$PROJECT_DIR/logs/combined.log',
|
422
|
+
time: true,
|
423
|
+
watch: false
|
424
|
+
},
|
425
|
+
{
|
426
|
+
name: 'specgen-admin',
|
427
|
+
script: 'npx',
|
428
|
+
args: 'serve -s admin/build -l 5001',
|
429
|
+
cwd: '$PROJECT_DIR',
|
430
|
+
env: {
|
431
|
+
NODE_ENV: 'production'
|
432
|
+
}
|
412
433
|
},
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
434
|
+
{
|
435
|
+
name: 'specgen-user',
|
436
|
+
script: 'npx',
|
437
|
+
args: 'serve -s user/build -l 5002',
|
438
|
+
cwd: '$PROJECT_DIR',
|
439
|
+
env: {
|
440
|
+
NODE_ENV: 'production'
|
441
|
+
}
|
442
|
+
}
|
443
|
+
]
|
422
444
|
}
|
423
445
|
EOF
|
424
446
|
|
425
447
|
mkdir -p logs
|
426
448
|
cp server/.env .env 2>/dev/null || true
|
427
449
|
|
428
|
-
if ! check_port
|
429
|
-
lsof -ti:
|
450
|
+
if ! check_port 80; then
|
451
|
+
lsof -ti:80 | xargs kill -9 2>/dev/null || true
|
430
452
|
sleep 2
|
431
453
|
fi
|
432
454
|
|
433
|
-
NODE_ENV=production PORT=
|
455
|
+
NODE_ENV=production PORT=80 HOST=$BIND_HOST $PM2_CMD start ecosystem.config.js
|
434
456
|
|
435
457
|
sleep 5
|
436
458
|
|
@@ -441,9 +463,9 @@ EOF
|
|
441
463
|
echo "🎉 SpecGen deployment completed!"
|
442
464
|
echo ""
|
443
465
|
echo "🌐 Access your application at:"
|
444
|
-
echo " - Main page: http://$PUBLIC_IP:
|
445
|
-
echo " - User app: http://$PUBLIC_IP:
|
446
|
-
echo " - Admin panel: http://$PUBLIC_IP:
|
466
|
+
echo " - Main page: http://$PUBLIC_IP:80/"
|
467
|
+
echo " - User app: http://$PUBLIC_IP:80/app/"
|
468
|
+
echo " - Admin panel: http://$PUBLIC_IP:80/admin/"
|
447
469
|
echo ""
|
448
470
|
echo "🔧 Binding: Server is bound to $BIND_HOST (${BIND_HOST:+publicly accessible})"
|
449
471
|
echo "📊 Management: npx pm2 status | npx pm2 logs specgen"
|
package/scripts/production.sh
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
|
3
|
-
# SpecGen Production Script - Low Memory, Port
|
3
|
+
# SpecGen Production Script - Low Memory, Port 80 with Cleanup
|
4
4
|
set -e
|
5
5
|
|
6
|
-
echo "🚀 Starting SpecGen in production mode on port
|
6
|
+
echo "🚀 Starting SpecGen in production mode on port 80..."
|
7
7
|
echo "🧹 Cleaning up existing processes..."
|
8
8
|
|
9
9
|
# Function to check if port is available
|
@@ -27,7 +27,7 @@ npx pm2 delete all 2>/dev/null || true
|
|
27
27
|
|
28
28
|
# Kill processes on ports we'll use
|
29
29
|
echo "Freeing ports..."
|
30
|
-
for port in
|
30
|
+
for port in 80 3000 3001 3002; do
|
31
31
|
if ! check_port $port; then
|
32
32
|
echo "Port $port is in use. Attempting to free it..."
|
33
33
|
lsof -ti:$port | xargs kill -9 2>/dev/null || true
|
@@ -38,8 +38,8 @@ done
|
|
38
38
|
# Stop nginx if it might interfere
|
39
39
|
if command -v nginx &> /dev/null && systemctl is-active --quiet nginx 2>/dev/null; then
|
40
40
|
echo "Nginx is running, checking for conflicts..."
|
41
|
-
if nginx -T 2>/dev/null | grep -q ":
|
42
|
-
echo "⚠️ Nginx is configured to use port
|
41
|
+
if nginx -T 2>/dev/null | grep -q ":80"; then
|
42
|
+
echo "⚠️ Nginx is configured to use port 80. You may need to reconfigure nginx."
|
43
43
|
fi
|
44
44
|
fi
|
45
45
|
|
@@ -138,13 +138,13 @@ fi
|
|
138
138
|
# CONFIGURE ENVIRONMENT
|
139
139
|
# ========================================
|
140
140
|
|
141
|
-
# Update server .env to use port
|
141
|
+
# Update server .env to use port 80
|
142
142
|
if [ -f "server/.env" ]; then
|
143
|
-
# Update or add PORT=
|
143
|
+
# Update or add PORT=80 to .env
|
144
144
|
if grep -q "^PORT=" server/.env; then
|
145
|
-
sed -i.bak "s/^PORT=.*/PORT=
|
145
|
+
sed -i.bak "s/^PORT=.*/PORT=80/" server/.env
|
146
146
|
else
|
147
|
-
echo "PORT=
|
147
|
+
echo "PORT=80" >> server/.env
|
148
148
|
fi
|
149
149
|
rm -f server/.env.bak
|
150
150
|
fi
|
@@ -153,7 +153,7 @@ fi
|
|
153
153
|
cat > server/.env.production << EOF
|
154
154
|
$(cat server/.env)
|
155
155
|
NODE_ENV=production
|
156
|
-
PORT=
|
156
|
+
PORT=80
|
157
157
|
EOF
|
158
158
|
|
159
159
|
# Create logs directory
|
@@ -164,17 +164,17 @@ mkdir -p logs
|
|
164
164
|
# ========================================
|
165
165
|
|
166
166
|
# Final port check
|
167
|
-
echo "Final check for port
|
168
|
-
if ! check_port
|
169
|
-
echo "Port
|
170
|
-
lsof -ti:
|
167
|
+
echo "Final check for port 80..."
|
168
|
+
if ! check_port 80; then
|
169
|
+
echo "Port 80 is still in use after cleanup. Force killing..."
|
170
|
+
lsof -ti:80 | xargs kill -9 2>/dev/null || true
|
171
171
|
sleep 2
|
172
172
|
fi
|
173
173
|
|
174
174
|
# Start production server
|
175
|
-
echo "Starting production server on port
|
175
|
+
echo "Starting production server on port 80..."
|
176
176
|
if [ "$CI" = "true" ]; then
|
177
177
|
echo "CI mode detected - skipping server start"
|
178
178
|
else
|
179
|
-
cd server && NODE_ENV=production PORT=
|
179
|
+
cd server && NODE_ENV=production PORT=80 npm start
|
180
180
|
fi
|
package/scripts/setup.sh
CHANGED
@@ -45,7 +45,7 @@ rm -rf ~/.pm2/logs/* 2>/dev/null || true
|
|
45
45
|
|
46
46
|
# 2. Kill processes on ports we'll use
|
47
47
|
echo "Freeing up ports..."
|
48
|
-
for port in
|
48
|
+
for port in 80 3000 3001 3002; do
|
49
49
|
if lsof -Pi :$port -sTCP:LISTEN -t >/dev/null 2>&1; then
|
50
50
|
echo "Killing processes on port $port..."
|
51
51
|
lsof -ti:$port | xargs kill -9 2>/dev/null || true
|
@@ -163,7 +163,7 @@ done
|
|
163
163
|
|
164
164
|
echo "🔧 Setting up environment files..."
|
165
165
|
|
166
|
-
# Server .env (default to port
|
166
|
+
# Server .env (default to port 80)
|
167
167
|
if [ ! -f server/.env ] || [ "$CI" = "true" ]; then
|
168
168
|
# If in CI mode, use a dummy key
|
169
169
|
if [ "$CI" = "true" ]; then
|
@@ -173,7 +173,7 @@ if [ ! -f server/.env ] || [ "$CI" = "true" ]; then
|
|
173
173
|
cat > server/.env << EOF
|
174
174
|
OPENAI_API_KEY=sk-test1234
|
175
175
|
NODE_ENV=test
|
176
|
-
PORT=
|
176
|
+
PORT=80
|
177
177
|
EOF
|
178
178
|
echo "Created test .env file for CI environment"
|
179
179
|
fi
|
@@ -196,7 +196,7 @@ EOF
|
|
196
196
|
# OpenAI API key
|
197
197
|
OPENAI_API_KEY=$OPENAI_KEY
|
198
198
|
NODE_ENV=development
|
199
|
-
PORT=
|
199
|
+
PORT=80
|
200
200
|
EOF
|
201
201
|
|
202
202
|
if [ "$KEY_PROVIDED" = true ]; then
|
@@ -210,7 +210,7 @@ fi
|
|
210
210
|
# Admin .env.development
|
211
211
|
if [ -d admin ]; then
|
212
212
|
cat > admin/.env.development << 'EOF'
|
213
|
-
REACT_APP_API_URL=http://localhost:
|
213
|
+
REACT_APP_API_URL=http://localhost:80
|
214
214
|
PORT=3001
|
215
215
|
SKIP_PREFLIGHT_CHECK=true
|
216
216
|
GENERATE_SOURCEMAP=false
|
@@ -220,7 +220,7 @@ fi
|
|
220
220
|
# User .env.development
|
221
221
|
if [ -d user ]; then
|
222
222
|
cat > user/.env.development << 'EOF'
|
223
|
-
REACT_APP_API_URL=http://localhost:
|
223
|
+
REACT_APP_API_URL=http://localhost:80
|
224
224
|
PORT=3002
|
225
225
|
SKIP_PREFLIGHT_CHECK=true
|
226
226
|
GENERATE_SOURCEMAP=false
|
@@ -239,25 +239,25 @@ echo " - Nginx specgen configurations"
|
|
239
239
|
echo " - Systemd services"
|
240
240
|
echo " - Docker containers"
|
241
241
|
echo " - Old project files"
|
242
|
-
echo " - Freed ports:
|
242
|
+
echo " - Freed ports: 80, 3000, 3001, 3002"
|
243
243
|
echo ""
|
244
244
|
echo "Next steps:"
|
245
245
|
if [ "$KEY_PROVIDED" = false ]; then
|
246
246
|
echo "1. Add your OpenAI API key to server/.env"
|
247
247
|
echo "2. Run 'npm run dev' to start all services"
|
248
|
-
echo "3. Or run 'npm run production' for production mode on port
|
248
|
+
echo "3. Or run 'npm run production' for production mode on port 80"
|
249
249
|
else
|
250
250
|
echo "1. Run 'npm run dev' to start all services"
|
251
|
-
echo "2. Or run 'npm run production' for production mode on port
|
251
|
+
echo "2. Or run 'npm run production' for production mode on port 80"
|
252
252
|
fi
|
253
253
|
echo ""
|
254
254
|
echo "Access URLs:"
|
255
|
-
echo " 🌐 Production: http://localhost:
|
256
|
-
echo " 📱 Production User: http://localhost:
|
257
|
-
echo " ⚙️ Production Admin: http://localhost:
|
258
|
-
echo " 📚 API Docs: http://localhost:
|
255
|
+
echo " 🌐 Production: http://localhost:80 (main app)"
|
256
|
+
echo " 📱 Production User: http://localhost:80/app"
|
257
|
+
echo " ⚙️ Production Admin: http://localhost:80/admin"
|
258
|
+
echo " 📚 API Docs: http://localhost:80/api-docs"
|
259
259
|
echo ""
|
260
260
|
echo "Development URLs:"
|
261
261
|
echo " 🌐 User Interface: http://localhost:3002"
|
262
262
|
echo " ⚙️ Admin Interface: http://localhost:3001"
|
263
|
-
echo " 🔧 API: http://localhost:
|
263
|
+
echo " 🔧 API: http://localhost:80"
|
@@ -1,104 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# SpecGen Deploy Script - Port 8080 Production Deployment
|
4
|
-
set -e
|
5
|
-
|
6
|
-
echo "🚀 Deploying SpecGen to production on port 8080..."
|
7
|
-
|
8
|
-
# Function to check if port is available
|
9
|
-
check_port() {
|
10
|
-
local port=$1
|
11
|
-
if lsof -Pi :$port -sTCP:LISTEN -t >/dev/null 2>&1; then
|
12
|
-
return 1 # Port in use
|
13
|
-
else
|
14
|
-
return 0 # Port available
|
15
|
-
fi
|
16
|
-
}
|
17
|
-
|
18
|
-
# Stop existing PM2 processes
|
19
|
-
echo "Stopping existing PM2 processes..."
|
20
|
-
npx pm2 stop all 2>/dev/null || true
|
21
|
-
npx pm2 delete all 2>/dev/null || true
|
22
|
-
|
23
|
-
# Kill any processes on port 8080
|
24
|
-
echo "Freeing port 8080..."
|
25
|
-
if ! check_port 8080; then
|
26
|
-
echo "Port 8080 is in use. Attempting to free it..."
|
27
|
-
lsof -ti:8080 | xargs kill -9 2>/dev/null || true
|
28
|
-
sleep 2
|
29
|
-
fi
|
30
|
-
|
31
|
-
# Run the production setup
|
32
|
-
echo "Running production setup..."
|
33
|
-
npm run production-low-memory &
|
34
|
-
SETUP_PID=$!
|
35
|
-
|
36
|
-
# Wait for setup to complete or timeout
|
37
|
-
TIMEOUT=60
|
38
|
-
COUNT=0
|
39
|
-
while [ $COUNT -lt $TIMEOUT ]; do
|
40
|
-
if ! kill -0 $SETUP_PID 2>/dev/null; then
|
41
|
-
echo "Production setup completed"
|
42
|
-
break
|
43
|
-
fi
|
44
|
-
sleep 1
|
45
|
-
COUNT=$((COUNT + 1))
|
46
|
-
done
|
47
|
-
|
48
|
-
# Kill setup process if it's still running
|
49
|
-
if kill -0 $SETUP_PID 2>/dev/null; then
|
50
|
-
echo "Setup taking too long, continuing with PM2 deployment..."
|
51
|
-
kill $SETUP_PID 2>/dev/null || true
|
52
|
-
fi
|
53
|
-
|
54
|
-
# Wait a moment for cleanup
|
55
|
-
sleep 2
|
56
|
-
|
57
|
-
# Create PM2 ecosystem configuration
|
58
|
-
echo "Creating PM2 ecosystem configuration..."
|
59
|
-
cat > ecosystem.config.js << 'EOF'
|
60
|
-
module.exports = {
|
61
|
-
apps: [{
|
62
|
-
name: 'specgen',
|
63
|
-
script: './server/index.js',
|
64
|
-
cwd: process.cwd(),
|
65
|
-
env: {
|
66
|
-
NODE_ENV: 'production',
|
67
|
-
PORT: 8080
|
68
|
-
},
|
69
|
-
instances: 1,
|
70
|
-
exec_mode: 'fork',
|
71
|
-
max_memory_restart: '500M',
|
72
|
-
error_file: './logs/err.log',
|
73
|
-
out_file: './logs/out.log',
|
74
|
-
log_file: './logs/combined.log',
|
75
|
-
time: true,
|
76
|
-
watch: false,
|
77
|
-
ignore_watch: ['node_modules', 'logs', '*.log']
|
78
|
-
}]
|
79
|
-
}
|
80
|
-
EOF
|
81
|
-
|
82
|
-
# Create logs directory
|
83
|
-
mkdir -p logs
|
84
|
-
|
85
|
-
# Start with PM2
|
86
|
-
echo "Starting SpecGen with PM2 on port 8080..."
|
87
|
-
NODE_ENV=production PORT=8080 npx pm2 start ecosystem.config.js
|
88
|
-
|
89
|
-
# Wait for startup
|
90
|
-
sleep 5
|
91
|
-
|
92
|
-
echo ""
|
93
|
-
echo "✅ SpecGen deployment completed!"
|
94
|
-
echo ""
|
95
|
-
echo "🌐 Access your application at:"
|
96
|
-
echo " - Main page: http://$(curl -s ifconfig.me 2>/dev/null || echo 'your-server'):8080/"
|
97
|
-
echo " - User app: http://$(curl -s ifconfig.me 2>/dev/null || echo 'your-server'):8080/app"
|
98
|
-
echo " - Admin panel: http://$(curl -s ifconfig.me 2>/dev/null || echo 'your-server'):8080/admin"
|
99
|
-
echo " - API docs: http://$(curl -s ifconfig.me 2>/dev/null || echo 'your-server'):8080/api-docs"
|
100
|
-
echo " - Health check: http://$(curl -s ifconfig.me 2>/dev/null || echo 'your-server'):8080/api/health"
|
101
|
-
echo ""
|
102
|
-
echo "📊 Check status with: npx pm2 status"
|
103
|
-
echo "📝 View logs with: npx pm2 logs specgen"
|
104
|
-
echo "🔄 Restart with: npx pm2 restart specgen"
|
@@ -1,129 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# SpecGen Production Script - Port 8080 Low Memory Version
|
4
|
-
set -e
|
5
|
-
|
6
|
-
echo "🚀 Starting SpecGen in production mode on port 8080 (Low Memory)..."
|
7
|
-
|
8
|
-
# Function to check if port is available
|
9
|
-
check_port() {
|
10
|
-
local port=$1
|
11
|
-
if lsof -Pi :$port -sTCP:LISTEN -t >/dev/null 2>&1; then
|
12
|
-
return 1 # Port in use
|
13
|
-
else
|
14
|
-
return 0 # Port available
|
15
|
-
fi
|
16
|
-
}
|
17
|
-
|
18
|
-
# Verify OpenAI API key
|
19
|
-
if [ -f "server/.env" ]; then
|
20
|
-
# In CI mode, skip API key validation
|
21
|
-
if [ "$CI" = "true" ]; then
|
22
|
-
echo "CI mode detected - skipping API key validation"
|
23
|
-
elif grep -q "OPENAI_API_KEY=your_openai_api_key_here" server/.env; then
|
24
|
-
echo "⚠️ No OpenAI API key detected!"
|
25
|
-
echo "Enter your OpenAI API key: "
|
26
|
-
read -r OPENAI_KEY
|
27
|
-
|
28
|
-
if [ -z "$OPENAI_KEY" ]; then
|
29
|
-
echo "❌ No API key provided. Cannot start in production mode."
|
30
|
-
exit 1
|
31
|
-
else
|
32
|
-
# Update the API key in the .env file
|
33
|
-
sed -i.bak "s/OPENAI_API_KEY=.*/OPENAI_API_KEY=$OPENAI_KEY/" server/.env
|
34
|
-
rm -f server/.env.bak
|
35
|
-
echo "✅ API key updated in server/.env"
|
36
|
-
fi
|
37
|
-
fi
|
38
|
-
else
|
39
|
-
echo "❌ server/.env file not found. Run 'npm run setup' first."
|
40
|
-
exit 1
|
41
|
-
fi
|
42
|
-
|
43
|
-
# Verify directories exist
|
44
|
-
for dir in server admin user; do
|
45
|
-
if [ ! -d "$dir" ]; then
|
46
|
-
echo "❌ $dir directory not found. Run 'npm run setup' first."
|
47
|
-
exit 1
|
48
|
-
fi
|
49
|
-
done
|
50
|
-
|
51
|
-
# Make sure node_modules exist in the server directory
|
52
|
-
if [ ! -d "server/node_modules" ]; then
|
53
|
-
echo "Installing server dependencies..."
|
54
|
-
cd server
|
55
|
-
# Create a .npmrc file that ignores engine requirements
|
56
|
-
echo "engine-strict=false" > .npmrc
|
57
|
-
npm install --no-fund --no-audit --production --maxsockets=2 --loglevel=warn
|
58
|
-
cd ..
|
59
|
-
fi
|
60
|
-
|
61
|
-
# Set production environment
|
62
|
-
export NODE_ENV=production
|
63
|
-
|
64
|
-
# Check if we need to build
|
65
|
-
if [ ! -d "admin/build" ] || [ ! -d "user/build" ]; then
|
66
|
-
echo "Building web interfaces (optimized mode)..."
|
67
|
-
|
68
|
-
# Admin build
|
69
|
-
if [ ! -d "admin/build" ]; then
|
70
|
-
echo "Building admin..."
|
71
|
-
cd admin
|
72
|
-
echo "engine-strict=false" > .npmrc
|
73
|
-
# Install only production dependencies
|
74
|
-
npm install --no-fund --no-audit --production --maxsockets=2 --loglevel=warn
|
75
|
-
# Set environment for smaller build
|
76
|
-
export GENERATE_SOURCEMAP=false
|
77
|
-
export SKIP_PREFLIGHT_CHECK=true
|
78
|
-
npm run build
|
79
|
-
cd ..
|
80
|
-
fi
|
81
|
-
|
82
|
-
# User build
|
83
|
-
if [ ! -d "user/build" ]; then
|
84
|
-
echo "Building user..."
|
85
|
-
cd user
|
86
|
-
echo "engine-strict=false" > .npmrc
|
87
|
-
# Install only production dependencies
|
88
|
-
npm install --no-fund --no-audit --production --maxsockets=2 --loglevel=warn
|
89
|
-
# Set environment for smaller build
|
90
|
-
export GENERATE_SOURCEMAP=false
|
91
|
-
export SKIP_PREFLIGHT_CHECK=true
|
92
|
-
npm run build
|
93
|
-
cd ..
|
94
|
-
fi
|
95
|
-
fi
|
96
|
-
|
97
|
-
# Update server .env to use port 8080
|
98
|
-
if [ -f "server/.env" ]; then
|
99
|
-
# Update or add PORT=8080 to .env
|
100
|
-
if grep -q "^PORT=" server/.env; then
|
101
|
-
sed -i.bak "s/^PORT=.*/PORT=8080/" server/.env
|
102
|
-
else
|
103
|
-
echo "PORT=8080" >> server/.env
|
104
|
-
fi
|
105
|
-
rm -f server/.env.bak
|
106
|
-
fi
|
107
|
-
|
108
|
-
# Create production-ready .env for server
|
109
|
-
cat > server/.env.production << EOF
|
110
|
-
$(cat server/.env)
|
111
|
-
NODE_ENV=production
|
112
|
-
PORT=8080
|
113
|
-
EOF
|
114
|
-
|
115
|
-
# Kill existing processes on port 8080 if needed
|
116
|
-
echo "Checking port 8080..."
|
117
|
-
if ! check_port 8080; then
|
118
|
-
echo "Port 8080 is in use. Attempting to free it..."
|
119
|
-
lsof -ti:8080 | xargs kill -9 2>/dev/null || true
|
120
|
-
sleep 2
|
121
|
-
fi
|
122
|
-
|
123
|
-
# Start production server
|
124
|
-
echo "Starting production server on port 8080..."
|
125
|
-
if [ "$CI" = "true" ]; then
|
126
|
-
echo "CI mode detected - skipping server start"
|
127
|
-
else
|
128
|
-
cd server && NODE_ENV=production PORT=8080 npm start
|
129
|
-
fi
|
@@ -1,203 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# SpecGen Low-Memory Setup Script
|
4
|
-
set -e
|
5
|
-
|
6
|
-
echo "🚀 Setting up SpecGen App (Low Memory Mode)..."
|
7
|
-
|
8
|
-
# Check Node.js
|
9
|
-
if ! command -v npm &> /dev/null; then
|
10
|
-
echo "❌ npm not found. Please install Node.js from https://nodejs.org/"
|
11
|
-
exit 1
|
12
|
-
fi
|
13
|
-
|
14
|
-
# Function to safely remove directories with permission handling
|
15
|
-
safe_remove() {
|
16
|
-
if [ -d "$1" ]; then
|
17
|
-
echo "Removing $1..."
|
18
|
-
chmod -R u+w "$1" 2>/dev/null || true
|
19
|
-
rm -rf "$1" 2>/dev/null || true
|
20
|
-
# If still exists, try with sudo
|
21
|
-
if [ -d "$1" ]; then
|
22
|
-
echo "Using elevated permissions to remove $1..."
|
23
|
-
sudo rm -rf "$1" 2>/dev/null || true
|
24
|
-
fi
|
25
|
-
fi
|
26
|
-
}
|
27
|
-
|
28
|
-
# Clean existing directories with proper permission handling
|
29
|
-
echo "Cleaning existing directories..."
|
30
|
-
safe_remove "server"
|
31
|
-
safe_remove "admin"
|
32
|
-
safe_remove "user"
|
33
|
-
rm -f *.tgz package 2>/dev/null || true
|
34
|
-
|
35
|
-
# Install dependencies one at a time with reduced memory usage
|
36
|
-
echo "📦 Installing dependencies (low memory mode)..."
|
37
|
-
npm install --no-fund --no-audit --ignore-scripts --production=false --maxsockets=2 --loglevel=warn
|
38
|
-
|
39
|
-
# Create a .npmrc file that ignores engine requirements
|
40
|
-
echo "engine-strict=false" > .npmrc
|
41
|
-
|
42
|
-
# Download npm packages one at a time
|
43
|
-
echo "📦 Downloading packages..."
|
44
|
-
npm pack @gv-sh/specgen-server --loglevel=warn
|
45
|
-
npm pack @gv-sh/specgen-admin --loglevel=warn
|
46
|
-
npm pack @gv-sh/specgen-user --loglevel=warn
|
47
|
-
|
48
|
-
# Extract packages
|
49
|
-
echo "📁 Extracting packages..."
|
50
|
-
|
51
|
-
# Extract server
|
52
|
-
if [ -f "gv-sh-specgen-server-"*.tgz ]; then
|
53
|
-
echo "Extracting server..."
|
54
|
-
tar -xzf gv-sh-specgen-server-*.tgz
|
55
|
-
mv package server
|
56
|
-
rm gv-sh-specgen-server-*.tgz
|
57
|
-
fi
|
58
|
-
|
59
|
-
# Extract admin
|
60
|
-
if [ -f "gv-sh-specgen-admin-"*.tgz ]; then
|
61
|
-
echo "Extracting admin..."
|
62
|
-
tar -xzf gv-sh-specgen-admin-*.tgz
|
63
|
-
mv package admin
|
64
|
-
rm gv-sh-specgen-admin-*.tgz
|
65
|
-
fi
|
66
|
-
|
67
|
-
# Extract user
|
68
|
-
if [ -f "gv-sh-specgen-user-"*.tgz ]; then
|
69
|
-
echo "Extracting user..."
|
70
|
-
tar -xzf gv-sh-specgen-user-*.tgz
|
71
|
-
mv package user
|
72
|
-
rm gv-sh-specgen-user-*.tgz
|
73
|
-
fi
|
74
|
-
|
75
|
-
# Patch package.json files to fix React scripts
|
76
|
-
echo "🔧 Patching package scripts..."
|
77
|
-
|
78
|
-
# Fix user package start script
|
79
|
-
if [ -f "user/package.json" ]; then
|
80
|
-
echo "Fixing user package start script..."
|
81
|
-
# Replace the start script to use react-scripts instead of missing scripts/start.js
|
82
|
-
sed -i.bak 's|"start": "cross-env PORT=3002 REACT_APP_API_URL=http://localhost:3000 node scripts/start.js"|"start": "cross-env PORT=3002 REACT_APP_API_URL=http://localhost:3000 react-scripts start"|g' user/package.json
|
83
|
-
rm -f user/package.json.bak
|
84
|
-
fi
|
85
|
-
|
86
|
-
# Fix admin package start script if needed
|
87
|
-
if [ -f "admin/package.json" ]; then
|
88
|
-
echo "Checking admin package start script..."
|
89
|
-
# Check if admin has similar issue
|
90
|
-
if grep -q "node scripts/start.js" admin/package.json; then
|
91
|
-
echo "Fixing admin package start script..."
|
92
|
-
sed -i.bak 's|node scripts/start.js|react-scripts start|g' admin/package.json
|
93
|
-
rm -f admin/package.json.bak
|
94
|
-
fi
|
95
|
-
fi
|
96
|
-
|
97
|
-
# Create .npmrc files with engine-strict=false in each directory
|
98
|
-
echo "Creating .npmrc files to ignore engine requirements..."
|
99
|
-
for dir in server admin user; do
|
100
|
-
if [ -d "$dir" ]; then
|
101
|
-
echo "engine-strict=false" > "$dir/.npmrc"
|
102
|
-
fi
|
103
|
-
done
|
104
|
-
|
105
|
-
# Install dependencies for each component with memory optimizations
|
106
|
-
echo "📚 Installing dependencies (low memory mode)..."
|
107
|
-
for dir in server admin user; do
|
108
|
-
if [ -d "$dir" ]; then
|
109
|
-
echo "Installing $dir dependencies..."
|
110
|
-
(cd "$dir" && npm install --no-fund --no-audit --ignore-scripts --loglevel=warn --production=false --maxsockets=2 --force --omit=dev)
|
111
|
-
else
|
112
|
-
echo "⚠️ Warning: $dir directory not found"
|
113
|
-
fi
|
114
|
-
done
|
115
|
-
|
116
|
-
# Setup environment files
|
117
|
-
echo "🔧 Setting up environment files..."
|
118
|
-
|
119
|
-
# Server .env
|
120
|
-
if [ ! -f server/.env ] || [ "$CI" = "true" ]; then
|
121
|
-
# If in CI mode, use a dummy key
|
122
|
-
if [ "$CI" = "true" ]; then
|
123
|
-
# If in CI environment and .env already exists, just use it
|
124
|
-
if [ -f server/.env ]; then
|
125
|
-
echo "Using existing .env file for CI environment"
|
126
|
-
else
|
127
|
-
# Create a CI .env file
|
128
|
-
cat > server/.env << EOF
|
129
|
-
OPENAI_API_KEY=sk-test1234
|
130
|
-
NODE_ENV=test
|
131
|
-
PORT=3000
|
132
|
-
EOF
|
133
|
-
echo "Created test .env file for CI environment"
|
134
|
-
fi
|
135
|
-
KEY_PROVIDED=true
|
136
|
-
else
|
137
|
-
# Normal interactive mode
|
138
|
-
# Prompt for OpenAI API key
|
139
|
-
echo "To use SpecGen, you need an OpenAI API key."
|
140
|
-
echo "Enter your OpenAI API key (or press enter to set it later): "
|
141
|
-
read -r OPENAI_KEY
|
142
|
-
|
143
|
-
# If key is provided, use it, otherwise use placeholder
|
144
|
-
if [ -z "$OPENAI_KEY" ]; then
|
145
|
-
OPENAI_KEY="your_openai_api_key_here"
|
146
|
-
KEY_PROVIDED=false
|
147
|
-
else
|
148
|
-
KEY_PROVIDED=true
|
149
|
-
fi
|
150
|
-
|
151
|
-
cat > server/.env << EOF
|
152
|
-
# OpenAI API key
|
153
|
-
OPENAI_API_KEY=$OPENAI_KEY
|
154
|
-
NODE_ENV=development
|
155
|
-
PORT=3000
|
156
|
-
EOF
|
157
|
-
|
158
|
-
if [ "$KEY_PROVIDED" = true ]; then
|
159
|
-
echo "✅ OpenAI API key saved to server/.env"
|
160
|
-
else
|
161
|
-
echo "⚠️ No OpenAI API key provided. You'll need to add it later to server/.env"
|
162
|
-
fi
|
163
|
-
fi
|
164
|
-
fi
|
165
|
-
|
166
|
-
# Admin .env.development
|
167
|
-
if [ -d admin ]; then
|
168
|
-
cat > admin/.env.development << 'EOF'
|
169
|
-
REACT_APP_API_URL=http://localhost:3000
|
170
|
-
PORT=3001
|
171
|
-
SKIP_PREFLIGHT_CHECK=true
|
172
|
-
GENERATE_SOURCEMAP=false
|
173
|
-
EOF
|
174
|
-
fi
|
175
|
-
|
176
|
-
# User .env.development
|
177
|
-
if [ -d user ]; then
|
178
|
-
cat > user/.env.development << 'EOF'
|
179
|
-
REACT_APP_API_URL=http://localhost:3000
|
180
|
-
PORT=3002
|
181
|
-
SKIP_PREFLIGHT_CHECK=true
|
182
|
-
GENERATE_SOURCEMAP=false
|
183
|
-
EOF
|
184
|
-
fi
|
185
|
-
|
186
|
-
echo "✅ Low-memory setup complete!"
|
187
|
-
echo ""
|
188
|
-
echo "Next steps:"
|
189
|
-
if [ "$KEY_PROVIDED" = false ]; then
|
190
|
-
echo "1. Add your OpenAI API key to server/.env"
|
191
|
-
echo "2. Use 'npm run dev' to start all services"
|
192
|
-
else
|
193
|
-
echo "1. Use 'npm run dev' to start all services"
|
194
|
-
fi
|
195
|
-
echo ""
|
196
|
-
echo "If you're deploying on a low-memory system, we recommend:"
|
197
|
-
echo "1. npm run build (to create optimized bundles)"
|
198
|
-
echo "2. npm run production (to start in production mode)"
|
199
|
-
echo ""
|
200
|
-
echo "Access URLs:"
|
201
|
-
echo " 🌐 User Interface: http://localhost:3002"
|
202
|
-
echo " ⚙️ Admin Interface: http://localhost:3001"
|
203
|
-
echo " 🔧 API: http://localhost:3000"
|