@gv-sh/specgen-app 0.5.0 → 0.6.1

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 CHANGED
@@ -1,292 +1,320 @@
1
1
  # SpecGen App - Complete Platform
2
2
 
3
- [![Version](https://img.shields.io/badge/version-0.5.0-blue.svg)](https://github.com/gv-sh/specgen-app)
3
+ [![Version](https://img.shields.io/badge/version-0.6.1-blue.svg)](https://github.com/gv-sh/specgen-app)
4
4
 
5
- A unified deployment package for the SpecGen speculative fiction generator platform.
5
+ A unified deployment package for the SpecGen speculative fiction generator platform. **Optimized for port 8080 deployment with low memory usage.**
6
6
 
7
- ## Components
7
+ ## 🚀 Quick Start
8
8
 
9
- - **Server**: Node.js API with OpenAI integration
10
- - **Admin**: React admin interface for content management
11
- - **User**: React user interface for story generation
9
+ ### One-Command Deployment (Recommended)
12
10
 
13
- ## Quick Start
11
+ ```bash
12
+ # Create project directory
13
+ mkdir specgen && cd specgen
14
14
 
15
- ### Using NPX (Recommended)
15
+ # Deploy everything in one command
16
+ npx @gv-sh/specgen-app deploy
17
+ ```
16
18
 
17
- ```bash
18
- # Create and enter your project directory
19
- mkdir specgen-project
20
- cd specgen-project
19
+ **What this does:**
20
+ - Downloads and sets up server, admin, and user components
21
+ - Builds React frontends optimized for production
22
+ - Configures everything for port 8080
23
+ - Starts with PM2 for process management
24
+ - Prompts for OpenAI API key
21
25
 
22
- # Run setup directly with npx
23
- npx @gv-sh/specgen-app setup
26
+ ## 🌐 Access URLs
24
27
 
25
- # Start in development mode
26
- npx @gv-sh/specgen-app dev
28
+ Once deployed, access your application at:
27
29
 
28
- # Or start in production mode
29
- npx @gv-sh/specgen-app production
30
- ```
30
+ - **Main Application**: http://your-server:8080/
31
+ - **User Interface**: http://your-server:8080/app
32
+ - **Admin Panel**: http://your-server:8080/admin
33
+ - **API Documentation**: http://your-server:8080/api-docs
34
+ - **Health Check**: http://your-server:8080/api/health
35
+ - **API Endpoints**: http://your-server:8080/api/*
36
+
37
+ ## 🖥️ Server Requirements
31
38
 
32
- ### Low Memory Mode for Small Servers
39
+ ### Minimum Requirements
40
+ - **Node.js**: 20.0.0 or higher
41
+ - **RAM**: 1GB minimum (2GB recommended)
42
+ - **Storage**: 2GB free space
43
+ - **OS**: Ubuntu 20.04+ (or similar Linux distribution)
33
44
 
34
- If you're deploying on a small EC2 instance or any server with limited RAM:
45
+ ### Quick Server Setup (Ubuntu)
35
46
 
36
47
  ```bash
37
- # First, add swap space to prevent out-of-memory errors
38
- sudo fallocate -l 2G /swapfile
39
- sudo chmod 600 /swapfile
40
- sudo mkswap /swapfile
41
- sudo swapon /swapfile
42
- echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
48
+ # Install Node.js 20+
49
+ curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
50
+ sudo apt-get install -y nodejs
43
51
 
44
- # Then use the low-memory versions of the commands
45
- npx @gv-sh/specgen-app setup-low-memory
46
- npx @gv-sh/specgen-app production-low-memory
52
+ # Verify installation
53
+ node --version # Should show v20.x.x or higher
54
+ npm --version
47
55
  ```
48
56
 
49
- ### Using NPM Scripts
57
+ ## 📋 Deployment Methods
50
58
 
51
- 1. **Setup**:
52
- ```bash
53
- npm run setup
54
- ```
55
- During setup, you'll be prompted to enter your OpenAI API key.
59
+ ### Method 1: Direct NPX Deployment (Easiest)
56
60
 
57
- 2. **Add OpenAI API Key** to `server/.env` if you skipped during setup
61
+ ```bash
62
+ # SSH into your server
63
+ ssh -i "your-key.pem" ubuntu@your-server-ip
64
+
65
+ # Create project and deploy
66
+ mkdir specgen && cd specgen
67
+ npx @gv-sh/specgen-app deploy
68
+ ```
58
69
 
59
- 3. **Start Development**:
60
- ```bash
61
- npm run dev
62
- ```
70
+ ### Method 2: Development Mode
63
71
 
64
- 4. **Start Production** (optimized build with API key validation):
65
- ```bash
66
- npm run production
67
- ```
72
+ For local development with separate ports:
68
73
 
69
- ## Access URLs
74
+ ```bash
75
+ mkdir specgen-dev && cd specgen-dev
76
+ npx @gv-sh/specgen-app setup
77
+ npx @gv-sh/specgen-app dev
78
+ ```
70
79
 
80
+ **Development URLs:**
71
81
  - User Interface: http://localhost:3002
72
- - Admin Interface: http://localhost:3001
73
- - API: http://localhost:3000
74
-
75
- ## Deployment Options
76
-
77
- ### Option 1: Quick NPX Deployment to Remote Server
78
-
79
- If you have SSH access to a server (like an EC2 instance), this is the fastest way to deploy:
80
-
81
- 1. **Save your SSH key** to a file (e.g., `key.pem`) and set permissions:
82
- ```bash
83
- chmod 400 key.pem
84
- ```
85
-
86
- 2. **SSH into your server**:
87
- ```bash
88
- ssh -i "key.pem" ubuntu@your-server-ip
89
- ```
90
-
91
- 3. **Install Node.js 18 or higher**:
92
- ```bash
93
- curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
94
- sudo apt-get install -y nodejs
95
- ```
96
-
97
- 4. **Install and run SpecGen**:
98
- ```bash
99
- # Add swap space to prevent out-of-memory errors
100
- sudo fallocate -l 2G /swapfile
101
- sudo chmod 600 /swapfile
102
- sudo mkswap /swapfile
103
- sudo swapon /swapfile
104
- echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
105
-
106
- # Create and enter project directory
107
- mkdir specgen
108
- cd specgen
109
-
110
- # Run the setup with low memory optimization
111
- npx @gv-sh/specgen-app setup-low-memory
112
-
113
- # Start in production mode with low memory optimization
114
- npx @gv-sh/specgen-app production-low-memory
115
- ```
116
-
117
- 5. **Keep the service running with PM2** (recommended):
118
- ```bash
119
- sudo npm install -g pm2
120
- # Use the low-memory production mode with PM2
121
- pm2 start "npx @gv-sh/specgen-app production-low-memory" --name "specgen"
122
- pm2 startup
123
- pm2 save
124
- ```
125
-
126
- 6. **Access your application**:
127
- - User Interface: http://your-server-ip:3002
128
- - Admin Interface: http://your-server-ip:3001
129
- - API: http://your-server-ip:3000
130
-
131
- ### Option 2: Global NPM Package Deployment
132
-
133
- #### Local Machine Deployment
134
-
135
- 1. **Install globally** (recommended for deployment):
136
- ```bash
137
- npm install -g @gv-sh/specgen-app
138
- ```
139
-
140
- 2. **Create a project directory**:
141
- ```bash
142
- mkdir specgen-project
143
- cd specgen-project
144
- ```
145
-
146
- 3. **Initialize and setup**:
147
- ```bash
148
- specgen-app setup
149
- ```
150
- During setup, you'll be prompted to enter your OpenAI API key.
151
-
152
- 4. **Start the application**:
153
- - Development mode: `specgen-app dev`
154
- - Production mode: `specgen-app production`
155
-
156
- #### Remote Server Deployment
157
-
158
- 1. **SSH into your server**:
159
- ```bash
160
- ssh -i "your-key.pem" username@your-server
161
- ```
162
-
163
- 2. **Install Node.js** (if not already installed):
164
- ```bash
165
- curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
166
- sudo apt-get install -y nodejs
167
- ```
168
-
169
- 3. **Create a project directory**:
170
- ```bash
171
- mkdir specgen
172
- cd specgen
173
- ```
174
-
175
- 4. **Install SpecGen globally**:
176
- ```bash
177
- npm install -g @gv-sh/specgen-app
178
- ```
179
-
180
- 5. **Setup the application**:
181
- ```bash
182
- specgen-app setup
183
- ```
184
-
185
- 6. **Start in production mode**:
186
- ```bash
187
- specgen-app production
188
- ```
189
-
190
- ### Option 3: Manual Deployment
191
-
192
- Alternatively, you can deploy manually using the repository:
193
-
194
- #### Build and Run Locally
82
+ - Admin Interface: http://localhost:3001
83
+ - API Server: http://localhost:8080
84
+
85
+ ### Method 3: Manual Deployment
86
+
87
+ If you prefer more control:
88
+
195
89
  ```bash
90
+ # Clone repository
196
91
  git clone https://github.com/gv-sh/specgen-app.git
197
92
  cd specgen-app
93
+
94
+ # Setup and deploy
198
95
  npm run setup
199
- npm run build
200
- npm run production
96
+ npm run deploy
201
97
  ```
202
98
 
203
- #### AWS Deployment Script
99
+ ## 🔧 Configuration
100
+
101
+ ### OpenAI API Key Setup
204
102
 
205
- 1. Launch Ubuntu 22.04 instance with SSH access
206
- 2. Run deployment script:
103
+ During deployment, you'll be prompted for your OpenAI API key. You can also set it manually:
207
104
 
208
105
  ```bash
209
- # On AWS instance
210
- wget https://github.com/gv-sh/specgen-app/raw/main/scripts/deploy.sh
211
- chmod +x deploy.sh
212
- sudo ./deploy.sh
106
+ # Create/edit the environment file
107
+ echo "OPENAI_API_KEY=your_openai_api_key_here" > server/.env
108
+ echo "NODE_ENV=production" >> server/.env
109
+ echo "PORT=8080" >> server/.env
110
+
111
+ # Restart the service
112
+ npx pm2 restart specgen --update-env
213
113
  ```
214
114
 
215
- ## Management Commands
115
+ ### Environment Variables
116
+
117
+ The deployment creates these configuration files:
118
+ - `server/.env` - Server configuration (port 8080, API key)
119
+ - `admin/.env.development` - Admin development settings
120
+ - `user/.env.development` - User development settings
121
+
122
+ ## 📊 Process Management
123
+
124
+ The deployment uses PM2 for process management:
216
125
 
217
- When using NPX or global installation:
218
126
  ```bash
219
127
  # Check status
220
- npx @gv-sh/specgen-app deploy:status
221
- # or when installed globally
222
- specgen-app deploy:status
223
-
224
- # Stop services
225
- npx @gv-sh/specgen-app deploy:stop
226
- # or
227
- specgen-app deploy:stop
228
-
229
- # Restart services
230
- npx @gv-sh/specgen-app deploy:restart
231
- # or
232
- specgen-app deploy:restart
233
-
234
- # Update to latest version
235
- npm update -g @gv-sh/specgen-app
128
+ npx pm2 status
129
+
130
+ # View logs
131
+ npx pm2 logs specgen
132
+
133
+ # Restart application
134
+ npx pm2 restart specgen
135
+
136
+ # Stop application
137
+ npx pm2 stop specgen
138
+
139
+ # Monitor resources
140
+ npx pm2 monit
236
141
  ```
237
142
 
238
- When using the repository:
143
+ ## 🔍 Troubleshooting
144
+
145
+ ### Common Issues and Solutions
146
+
147
+ #### 1. Port 8080 Already in Use
239
148
  ```bash
240
- # Stop services
241
- npm run deploy:stop
149
+ # Check what's using the port
150
+ sudo lsof -i :8080
242
151
 
243
- # Restart services
244
- npm run deploy:restart
152
+ # Kill the process
153
+ sudo lsof -ti:8080 | xargs kill -9
245
154
 
246
- # Update to latest
247
- npm run deploy:update
155
+ # Redeploy
156
+ npx @gv-sh/specgen-app deploy
157
+ ```
248
158
 
249
- # Check status
250
- npm run deploy:status
159
+ #### 2. Frontend Not Loading (404 Errors)
160
+ ```bash
161
+ # Check if builds exist
162
+ ls -la admin/build/
163
+ ls -la user/build/
164
+
165
+ # If missing, manually rebuild
166
+ cd admin && npm install && GENERATE_SOURCEMAP=false PUBLIC_URL=/admin npm run build
167
+ cd ../user && npm install && GENERATE_SOURCEMAP=false REACT_APP_API_URL=/api PUBLIC_URL=/app npm run build
251
168
 
252
- # Create backup
253
- npm run deploy:backup
169
+ # Restart server
170
+ npx pm2 restart specgen
254
171
  ```
255
172
 
256
- ## Available Commands
173
+ #### 3. OpenAI API Key Issues
174
+ ```bash
175
+ # Check current environment
176
+ npx pm2 env 0
177
+
178
+ # Update API key
179
+ echo "OPENAI_API_KEY=your_new_key_here" > server/.env
180
+ echo "NODE_ENV=production" >> server/.env
181
+ echo "PORT=8080" >> server/.env
182
+
183
+ # Restart with new environment
184
+ npx pm2 restart specgen --update-env
185
+ ```
186
+
187
+ #### 4. Out of Memory Errors
188
+ ```bash
189
+ # Add swap space (2GB recommended)
190
+ sudo fallocate -l 2G /swapfile
191
+ sudo chmod 600 /swapfile
192
+ sudo mkswap /swapfile
193
+ sudo swapon /swapfile
194
+ echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
195
+
196
+ # Verify swap is active
197
+ free -h
198
+ ```
199
+
200
+ #### 5. Node.js Version Issues
201
+ ```bash
202
+ # Check current version
203
+ node --version
204
+
205
+ # If less than v20, update:
206
+ curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
207
+ sudo apt-get install -y nodejs
208
+ ```
209
+
210
+ ### Debugging Commands
211
+
212
+ ```bash
213
+ # Test API health
214
+ curl http://localhost:8080/api/health
215
+
216
+ # Test main page response
217
+ curl -I http://localhost:8080/
257
218
 
258
- The following commands are available when using `npx @gv-sh/specgen-app` or `specgen-app` (if installed globally):
219
+ # Check server logs
220
+ npx pm2 logs specgen --lines 50
259
221
 
260
- - `setup` - Set up the SpecGen application
261
- - `setup-low-memory` - Set up the SpecGen application with memory optimizations
262
- - `production` - Run the application in production mode
263
- - `production-low-memory` - Run the application in production mode with memory optimizations
264
- - `dev` - Run the application in development mode
265
- - `deploy` - Deploy the application
266
- - `deploy:stop` - Stop the deployed application
267
- - `deploy:restart` - Restart the deployed application
268
- - `deploy:update` - Update the deployed application
269
- - `deploy:status` - Check the status of the deployed application
270
- - `deploy:backup` - Create a backup of the deployed application
271
- - `troubleshoot` - Run troubleshooting checks
222
+ # Check build status
223
+ ls -la */build/ 2>/dev/null || echo "No builds found"
272
224
 
273
- ## Troubleshooting
225
+ # Check processes listening on port 8080
226
+ sudo netstat -tlnp | grep :8080
227
+ ```
274
228
 
275
- If you encounter issues:
229
+ ### Manual Build Process
230
+
231
+ If automatic builds fail, try manual building:
276
232
 
277
233
  ```bash
278
- # Using npx
279
- npx @gv-sh/specgen-app troubleshoot
234
+ # Stop current deployment
235
+ npx pm2 stop specgen
236
+
237
+ # Manual server setup
238
+ npm pack @gv-sh/specgen-server
239
+ tar -xzf gv-sh-specgen-server-*.tgz
240
+ mv package server
241
+ cd server && npm install && cd ..
242
+
243
+ # Manual admin build
244
+ npm pack @gv-sh/specgen-admin
245
+ tar -xzf gv-sh-specgen-admin-*.tgz
246
+ mv package admin
247
+ cd admin && npm install && GENERATE_SOURCEMAP=false PUBLIC_URL=/admin npm run build && cd ..
248
+
249
+ # Manual user build
250
+ npm pack @gv-sh/specgen-user
251
+ tar -xzf gv-sh-specgen-user-*.tgz
252
+ mv package user
253
+ cd user && npm install && GENERATE_SOURCEMAP=false REACT_APP_API_URL=/api PUBLIC_URL=/app npm run build && cd ..
254
+
255
+ # Restart deployment
256
+ npx pm2 start server/index.js --name specgen
257
+ ```
258
+
259
+ ## 🚨 Known Issues
260
+
261
+ ### Current Limitations
262
+ - **Memory Usage**: Requires at least 1GB RAM for builds
263
+ - **Build Time**: Initial deployment can take 5-10 minutes
264
+ - **SQLite Dependencies**: May require build tools on some systems
265
+ - **Static File Serving**: Builds must complete successfully for frontend access
266
+
267
+ ### AWS EC2 Specific
268
+ - **Security Groups**: Ensure port 8080 is open in your security group
269
+ - **Instance Type**: t2.micro may struggle with builds (t2.small recommended)
270
+ - **Storage**: Ensure at least 2GB free space for node_modules and builds
271
+
272
+ ## 📚 API Documentation
273
+
274
+ Once deployed, access interactive API documentation at:
275
+ - **Swagger UI**: http://your-server:8080/api-docs
280
276
 
281
- # Using global installation
282
- specgen-app troubleshoot
277
+ ### Key API Endpoints
278
+ - `GET /api/health` - Health check and system status
279
+ - `POST /api/generate` - Generate speculative fiction content
280
+ - `GET /api/categories` - List available story categories
281
+ - `GET /api/parameters` - Get generation parameters
283
282
 
284
- # For repository installation
285
- npm run troubleshoot
283
+ ## 🔄 Updates and Maintenance
284
+
285
+ ### Updating SpecGen
286
+ ```bash
287
+ # Stop current deployment
288
+ npx pm2 stop specgen
289
+
290
+ # Clean up old installation
291
+ rm -rf admin user server node_modules
292
+
293
+ # Deploy latest version
294
+ npx @gv-sh/specgen-app deploy
286
295
  ```
287
296
 
288
- This will check your setup and identify common problems.
297
+ ### Backup Important Data
298
+ ```bash
299
+ # Backup database and configurations
300
+ tar -czf specgen-backup-$(date +%Y%m%d).tar.gz server/data server/.env logs/
301
+ ```
302
+
303
+ ## 🤝 Support
304
+
305
+ ### Getting Help
306
+ - **Health Check**: Visit http://your-server:8080/api/health
307
+ - **Logs**: Run `npx pm2 logs specgen`
308
+ - **Issues**: [GitHub Issues](https://github.com/gv-sh/specgen-app/issues)
309
+ - **Status**: Run `npx pm2 status` to check process status
310
+
311
+ ### Reporting Bugs
312
+ When reporting issues, please include:
313
+ - Output of `npx pm2 logs specgen`
314
+ - Output of `curl http://localhost:8080/api/health`
315
+ - Your server specifications (RAM, OS version, Node.js version)
316
+ - Any error messages from the deployment process
289
317
 
290
- ## Environment Variables
318
+ ## 📄 License
291
319
 
292
- The setup script creates necessary environment files automatically. You only need to add your OpenAI API key during setup or later to `server/.env`.
320
+ This project is licensed under the ISC License.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gv-sh/specgen-app",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "Complete SpecGen application with server, admin, and user interfaces",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -8,20 +8,15 @@
8
8
  },
9
9
  "scripts": {
10
10
  "setup": "chmod +x scripts/setup.sh && ./scripts/setup.sh",
11
- "setup-low-memory": "chmod +x scripts/setup-low-memory.sh && ./scripts/setup-low-memory.sh",
12
11
  "dev": "chmod +x scripts/dev.sh && ./scripts/dev.sh",
13
12
  "build": "cd admin && npm run build && cd ../user && npm run build",
14
13
  "start": "cd server && npm start",
15
14
  "production": "chmod +x scripts/production.sh && ./scripts/production.sh",
16
- "production-low-memory": "chmod +x scripts/production-low-memory.sh && ./scripts/production-low-memory.sh",
17
- "make-executable": "chmod +x scripts/make-executable.sh && ./scripts/make-executable.sh",
18
15
  "deploy": "chmod +x scripts/deploy.sh && ./scripts/deploy.sh",
16
+ "make-executable": "chmod +x scripts/make-executable.sh && ./scripts/make-executable.sh",
19
17
  "deploy:stop": "chmod +x scripts/stop.sh && ./scripts/stop.sh",
20
18
  "deploy:restart": "chmod +x scripts/restart.sh && ./scripts/restart.sh",
21
- "deploy:update": "chmod +x scripts/update.sh && ./scripts/update.sh",
22
19
  "deploy:status": "chmod +x scripts/status.sh && ./scripts/status.sh",
23
- "deploy:backup": "chmod +x scripts/backup.sh && ./scripts/backup.sh",
24
- "troubleshoot": "chmod +x scripts/troubleshoot.sh && ./scripts/troubleshoot.sh",
25
20
  "postinstall": "chmod +x bin/cli.js"
26
21
  },
27
22
  "dependencies": {
@@ -0,0 +1,104 @@
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"