ezpm2gui 1.0.0 → 1.2.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 +202 -14
- package/bin/ezpm2gui.js +40 -44
- package/bin/ezpm2gui.ts +51 -0
- package/bin/generate-ecosystem.js +24 -22
- package/bin/generate-ecosystem.ts +56 -0
- package/dist/server/config/project-configs.json +236 -0
- package/dist/server/index.js +64 -19
- package/dist/server/logs/deployment.log +12 -0
- package/dist/server/routes/clusterManagement.d.ts +3 -0
- package/dist/server/routes/clusterManagement.js +152 -0
- package/dist/server/routes/deployApplication.d.ts +3 -0
- package/dist/server/routes/deployApplication.js +310 -0
- package/dist/server/routes/logStreaming.d.ts +5 -0
- package/dist/server/routes/logStreaming.js +276 -0
- package/dist/server/routes/modules.d.ts +3 -0
- package/dist/server/routes/modules.js +106 -0
- package/dist/server/routes/processConfig.d.ts +3 -0
- package/dist/server/routes/processConfig.js +118 -0
- package/dist/server/routes/remoteConnections.d.ts +3 -0
- package/dist/server/routes/remoteConnections.js +634 -0
- package/dist/server/services/ProjectSetupService.d.ts +72 -0
- package/dist/server/services/ProjectSetupService.js +327 -0
- package/dist/server/utils/dialog.d.ts +1 -0
- package/dist/server/utils/dialog.js +16 -0
- package/dist/server/utils/encryption.d.ts +12 -0
- package/dist/server/utils/encryption.js +72 -0
- package/dist/server/utils/pm2-connection.d.ts +16 -0
- package/dist/server/utils/pm2-connection.js +141 -0
- package/dist/server/utils/remote-connection.d.ts +152 -0
- package/dist/server/utils/remote-connection.js +590 -0
- package/dist/server/utils/upload.d.ts +3 -0
- package/dist/server/utils/upload.js +39 -0
- package/package.json +65 -49
- package/src/client/build/asset-manifest.json +6 -6
- package/src/client/build/favicon.ico +2 -0
- package/src/client/build/index.html +1 -1
- package/src/client/build/logo192.svg +7 -0
- package/src/client/build/logo512.svg +7 -0
- package/src/client/build/manifest.json +5 -6
- package/src/client/build/static/css/main.672b8f26.css +2 -0
- package/src/client/build/static/css/main.672b8f26.css.map +1 -0
- package/src/client/build/static/js/main.31323a04.js +156 -0
- package/src/client/build/static/js/{main.dde30e92.js.LICENSE.txt → main.31323a04.js.LICENSE.txt} +19 -0
- package/src/client/build/static/js/main.31323a04.js.map +1 -0
- package/ .npmignore +0 -39
- package/install.bat +0 -22
- package/install.sh +0 -23
- package/src/client/build/static/css/main.c1cbda3a.css +0 -2
- package/src/client/build/static/css/main.c1cbda3a.css.map +0 -1
- package/src/client/build/static/js/main.dde30e92.js +0 -3
- package/src/client/build/static/js/main.dde30e92.js.map +0 -1
- package/src/client/package-lock.json +0 -16192
- package/src/client/package.json +0 -39
- package/src/client/public/index.html +0 -20
- package/src/client/public/manifest.json +0 -25
- package/src/index.ts +0 -24
- package/src/server/index.ts +0 -240
- package/tsconfig.json +0 -18
package/README.md
CHANGED
|
@@ -1,19 +1,92 @@
|
|
|
1
1
|
# ezPM2GUI
|
|
2
2
|
|
|
3
|
-
A modern web-based graphical user interface for the PM2 process manager.
|
|
3
|
+
A modern web-based graphical user interface for the PM2 process manager, built with TypeScript and Material UI.
|
|
4
4
|
|
|
5
|
-

|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
|
-
- Real-time process monitoring
|
|
10
|
-
- Process management
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
- WebSocket for live updates
|
|
14
|
-
- Process CPU and memory charts
|
|
15
|
-
- Filter processes by status or name
|
|
16
|
-
-
|
|
9
|
+
- 🔍 **Real-time process monitoring** - Keep track of all your PM2 processes in real-time
|
|
10
|
+
- 🎮 **Process management** - Start, stop, restart, and delete processes with one click
|
|
11
|
+
- 📊 **System metrics dashboard** - Monitor CPU, memory usage, and uptime
|
|
12
|
+
- 📝 **Enhanced log streaming** - View and filter logs from multiple processes simultaneously
|
|
13
|
+
- 🔄 **WebSocket for live updates** - Get instant updates without refreshing
|
|
14
|
+
- 📈 **Process CPU and memory charts** - Visualize performance metrics over time
|
|
15
|
+
- 🔍 **Filter processes by status or name** - Quickly find the processes you need
|
|
16
|
+
- 🌙 **Dark mode support** - Easy on the eyes for late-night monitoring
|
|
17
|
+
- 🖥️ **Cluster management** - Easily scale your Node.js applications
|
|
18
|
+
- 📦 **Application deployment** - Deploy new applications directly from the UI
|
|
19
|
+
- ⚙️ **Ecosystem configuration** - Create and manage your PM2 ecosystem files
|
|
20
|
+
- 🧩 **PM2 modules support** - Manage and configure PM2 modules
|
|
21
|
+
- 🌐 **Modern UI with Material UI components** - Clean and intuitive interface
|
|
22
|
+
- 🔒 **Fully typed with TypeScript** - Robust and maintainable codebase
|
|
23
|
+
|
|
24
|
+
## Detailed Features
|
|
25
|
+
|
|
26
|
+
### Process Monitoring
|
|
27
|
+
Monitor all your PM2 processes in real-time with detailed information on CPU usage, memory consumption, uptime, and status. The intuitive interface makes it easy to identify issues at a glance.
|
|
28
|
+
|
|
29
|
+
### Application Deployment
|
|
30
|
+
Deploy new Node.js applications to PM2 directly from the UI. Configure all the necessary options including:
|
|
31
|
+
- Application name and script path
|
|
32
|
+
- Working directory
|
|
33
|
+
- Number of instances for load balancing
|
|
34
|
+
- Execution mode (fork or cluster)
|
|
35
|
+
- Auto-restart options
|
|
36
|
+
- Memory threshold for restarts
|
|
37
|
+
- Environment variables
|
|
38
|
+
|
|
39
|
+
### Cluster Management
|
|
40
|
+
Easily scale your Node.js applications with the cluster management interface. Add or remove instances on the fly and switch between fork and cluster execution modes for optimal performance.
|
|
41
|
+
|
|
42
|
+
### Log Streaming
|
|
43
|
+
View and filter logs from multiple processes simultaneously with the enhanced log streaming interface. Features include:
|
|
44
|
+
- Real-time log updates
|
|
45
|
+
- Filtering by log level or content
|
|
46
|
+
- Pausing and resuming log streams
|
|
47
|
+
- Log retention configuration
|
|
48
|
+
|
|
49
|
+
### Ecosystem Configuration
|
|
50
|
+
Generate and manage PM2 ecosystem configuration files directly from the UI. This makes it easy to set up complex application deployments and share configurations across your team.
|
|
51
|
+
|
|
52
|
+
### PM2 Modules
|
|
53
|
+
Manage and configure PM2 modules to extend the functionality of your PM2 installation. Install, update, and remove modules with a few clicks.
|
|
54
|
+
|
|
55
|
+
### System Metrics
|
|
56
|
+
Monitor key system metrics including:
|
|
57
|
+
- CPU usage and number of cores
|
|
58
|
+
- Memory usage and availability
|
|
59
|
+
- System uptime
|
|
60
|
+
- Load averages (1, 5, and 15 minutes)
|
|
61
|
+
|
|
62
|
+
### User Interface Customization
|
|
63
|
+
Customize the ezPM2GUI interface to suit your preferences:
|
|
64
|
+
- Toggle dark mode for reduced eye strain
|
|
65
|
+
- Select color themes
|
|
66
|
+
- Configure dashboard refresh intervals
|
|
67
|
+
- Adjust log display settings
|
|
68
|
+
|
|
69
|
+
## Screenshots
|
|
70
|
+
|
|
71
|
+
### Process Monitor
|
|
72
|
+
The main dashboard provides a comprehensive view of all your PM2 processes, showing CPU usage, memory consumption, uptime, and status at a glance.
|
|
73
|
+
|
|
74
|
+

|
|
75
|
+
|
|
76
|
+
### System Metrics & Process Management
|
|
77
|
+
Monitor your system resources and manage PM2 processes with intuitive controls for start, stop, restart, and delete operations.
|
|
78
|
+
|
|
79
|
+

|
|
80
|
+
|
|
81
|
+
### Deploy New Application
|
|
82
|
+
Easily deploy new Node.js applications to PM2 with a user-friendly form interface. Configure all PM2 options including instances, execution mode, working directory, and environment variables.
|
|
83
|
+
|
|
84
|
+

|
|
85
|
+
|
|
86
|
+
### Application Settings
|
|
87
|
+
Customize the ezPM2GUI interface and configure your PM2 connection settings to match your environment.
|
|
88
|
+
|
|
89
|
+

|
|
17
90
|
|
|
18
91
|
## Installation
|
|
19
92
|
|
|
@@ -37,6 +110,12 @@ npm install ezpm2gui
|
|
|
37
110
|
# Start the ezPM2GUI web interface
|
|
38
111
|
ezpm2gui
|
|
39
112
|
|
|
113
|
+
# Start on a specific port
|
|
114
|
+
ezpm2gui --port 4000
|
|
115
|
+
|
|
116
|
+
# Start bound to all network interfaces
|
|
117
|
+
ezpm2gui --host 0.0.0.0
|
|
118
|
+
|
|
40
119
|
# Generate a sample PM2 ecosystem config
|
|
41
120
|
ezpm2gui-generate-ecosystem
|
|
42
121
|
```
|
|
@@ -66,7 +145,7 @@ http://localhost:3001
|
|
|
66
145
|
|
|
67
146
|
## Requirements
|
|
68
147
|
|
|
69
|
-
- Node.js
|
|
148
|
+
- Node.js 16.x or later
|
|
70
149
|
- PM2 installed globally (`npm install -g pm2`)
|
|
71
150
|
|
|
72
151
|
## Configuration
|
|
@@ -76,27 +155,136 @@ ezPM2GUI uses environment variables for configuration:
|
|
|
76
155
|
- `PORT`: The port to run the server on (default: 3001)
|
|
77
156
|
- `HOST`: The host to bind to (default: localhost)
|
|
78
157
|
|
|
158
|
+
## Load Balancing with PM2
|
|
159
|
+
|
|
160
|
+
ezPM2GUI provides an easy interface to manage PM2's load balancing capabilities:
|
|
161
|
+
|
|
162
|
+
### Setting Up Load Balancing
|
|
163
|
+
|
|
164
|
+
1. **Deploy a new application or modify an existing one**:
|
|
165
|
+
- Set the number of instances to greater than 1 (or 0/-1 for max instances based on CPU cores)
|
|
166
|
+
- Choose "Cluster" as the execution mode for optimal load balancing
|
|
167
|
+
|
|
168
|
+
2. **Manage your cluster**:
|
|
169
|
+
- Use the Cluster Management section to scale instances up or down
|
|
170
|
+
- Switch between fork and cluster execution modes
|
|
171
|
+
- Reload all instances with zero downtime
|
|
172
|
+
|
|
173
|
+
### How Load Balancing Works
|
|
174
|
+
|
|
175
|
+
PM2 provides built-in load balancing when you run your Node.js applications in cluster mode with multiple instances:
|
|
176
|
+
|
|
177
|
+
- **Cluster Mode**: In this mode, PM2 uses Node.js's cluster module to create multiple worker processes that share the same server port
|
|
178
|
+
- **Multiple Instances**: Incoming requests are automatically distributed across your instances
|
|
179
|
+
- **Zero Downtime Reloads**: When updating your application, PM2 can reload instances one by one to avoid downtime
|
|
180
|
+
|
|
181
|
+
### Best Practices
|
|
182
|
+
|
|
183
|
+
- For CPU-intensive applications, use a number of instances equal to the number of CPU cores
|
|
184
|
+
- For I/O-intensive applications, you can use more instances than CPU cores
|
|
185
|
+
- Always use cluster mode for load balancing to ensure port sharing between instances
|
|
186
|
+
- Use the reload feature instead of restart for zero-downtime deployments
|
|
187
|
+
|
|
79
188
|
## Development
|
|
80
189
|
|
|
81
190
|
See [DEVELOPMENT.md](DEVELOPMENT.md) for detailed development instructions.
|
|
82
191
|
|
|
83
192
|
```bash
|
|
84
193
|
# Clone the repository
|
|
85
|
-
git clone https://github.com/
|
|
194
|
+
git clone https://github.com/thechandanbhagat/ezpm2gui.git
|
|
86
195
|
cd ezpm2gui
|
|
87
196
|
|
|
88
197
|
# Install dependencies and build
|
|
89
198
|
./install.sh # On Linux/macOS
|
|
90
199
|
install.bat # On Windows
|
|
91
200
|
|
|
92
|
-
# Start
|
|
201
|
+
# Start in development mode
|
|
202
|
+
npm run dev
|
|
203
|
+
|
|
204
|
+
# Build the application
|
|
205
|
+
npm run build
|
|
206
|
+
|
|
207
|
+
# Start the application (production mode)
|
|
93
208
|
npm start
|
|
94
209
|
```
|
|
95
210
|
|
|
211
|
+
### Project Structure
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
ezpm2gui/
|
|
215
|
+
├── bin/ # CLI entry points
|
|
216
|
+
├── dist/ # Compiled output
|
|
217
|
+
├── docs/ # Documentation
|
|
218
|
+
├── screenshots/ # Application screenshots
|
|
219
|
+
├── scripts/ # Build and utility scripts
|
|
220
|
+
├── src/ # Source code
|
|
221
|
+
│ ├── client/ # React frontend
|
|
222
|
+
│ │ ├── public/ # Static assets
|
|
223
|
+
│ │ └── src/ # React components and logic
|
|
224
|
+
│ │ ├── components/ # UI components
|
|
225
|
+
│ │ └── types/ # TypeScript types for client
|
|
226
|
+
│ ├── server/ # Express backend
|
|
227
|
+
│ │ ├── routes/ # API routes
|
|
228
|
+
│ │ └── utils/ # Server utilities
|
|
229
|
+
│ └── types/ # Shared TypeScript types
|
|
230
|
+
└── test/ # Test files
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Contributing
|
|
234
|
+
|
|
235
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
236
|
+
|
|
237
|
+
1. Fork the repository
|
|
238
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
239
|
+
3. Make your changes
|
|
240
|
+
4. Run the tests to ensure everything works
|
|
241
|
+
5. Commit your changes using our [commit guidelines](./docs/COMMIT_GUIDE.md)
|
|
242
|
+
6. Push to the branch (`git push origin feature/amazing-feature`)
|
|
243
|
+
7. Open a Pull Request
|
|
244
|
+
|
|
245
|
+
### Coding Style
|
|
246
|
+
|
|
247
|
+
This project follows standardized TypeScript conventions and uses ESLint for code quality. Before submitting a pull request, please ensure your code follows these guidelines by running:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
npm run lint
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## FAQ
|
|
254
|
+
|
|
255
|
+
### Q: How does ezPM2GUI differ from pm2-gui and PM2 Plus?
|
|
256
|
+
|
|
257
|
+
A: ezPM2GUI is a modern, TypeScript-based alternative to pm2-gui with a more user-friendly interface and additional features. Unlike PM2 Plus, it's completely free and open-source, running locally on your server rather than in the cloud.
|
|
258
|
+
|
|
259
|
+
### Q: Can I use ezPM2GUI with PM2 running on a different machine?
|
|
260
|
+
|
|
261
|
+
A: Yes, you can configure ezPM2GUI to connect to a remote PM2 installation. You'll need to specify the connection details in the application settings.
|
|
262
|
+
|
|
263
|
+
### Q: How do I generate an ecosystem file from my existing processes?
|
|
264
|
+
|
|
265
|
+
A: Use the `ezpm2gui-generate-ecosystem` command-line tool, or visit the Ecosystem Config section in the web UI.
|
|
266
|
+
|
|
267
|
+
### Q: Can ezPM2GUI handle a large number of processes?
|
|
268
|
+
|
|
269
|
+
A: Yes, ezPM2GUI is designed to handle dozens of processes efficiently. The UI is optimized to present large amounts of information in a digestible format.
|
|
270
|
+
|
|
271
|
+
### Q: Is ezPM2GUI secure?
|
|
272
|
+
|
|
273
|
+
A: By default, ezPM2GUI binds to localhost for security reasons. If you expose the interface to other machines, consider adding authentication through a reverse proxy like Nginx.
|
|
274
|
+
|
|
275
|
+
## Related Projects
|
|
276
|
+
|
|
277
|
+
- [PM2](https://github.com/Unitech/pm2) - The process manager that ezPM2GUI works with
|
|
278
|
+
- [pm2-gui](https://github.com/Tjatse/pm2-gui) - The original inspiration for this project
|
|
279
|
+
|
|
96
280
|
## License
|
|
97
281
|
|
|
98
282
|
ISC
|
|
99
283
|
|
|
100
284
|
## Credits
|
|
101
285
|
|
|
102
|
-
Built with ❤️ as a modern alternative to pm2-gui
|
|
286
|
+
Built with ❤️ by [Chandan Bhagat](https://github.com/thechandanbhagat) as a modern alternative to pm2-gui.
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
**Note**: ezPM2GUI is not officially affiliated with PM2 or PM2 Plus. It's an independent tool that interfaces with the PM2 process manager.
|
package/bin/ezpm2gui.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// Log startup message
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
// Determine the path to the server executable
|
|
11
|
+
const serverPath = path_1.default.join(__dirname, '../dist/server/index.js');
|
|
12
|
+
// Check if the server file exists
|
|
13
|
+
if (!fs_1.default.existsSync(serverPath)) {
|
|
14
|
+
console.error('Error: Server executable not found. Please make sure the package is built correctly.');
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
// Start the server
|
|
18
|
+
const server = (0, child_process_1.spawn)('node', [serverPath], { stdio: 'inherit' });
|
|
19
|
+
// Log startup message
|
|
20
20
|
console.log('\x1b[36m%s\x1b[0m', `
|
|
21
21
|
╔════════════════════════════════════╗
|
|
22
22
|
║ ezPM2GUI Started ║
|
|
@@ -25,28 +25,24 @@ console.log('\x1b[36m%s\x1b[0m', `
|
|
|
25
25
|
Web interface available at: \x1b[1mhttp://localhost:3001\x1b[0m
|
|
26
26
|
|
|
27
27
|
Press Ctrl+C to stop the server.
|
|
28
|
-
`);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
process.on('SIGTERM', () => {
|
|
50
|
-
console.log('Shutting down ezPM2GUI...');
|
|
51
|
-
server.kill('SIGTERM');
|
|
52
|
-
});
|
|
28
|
+
`);
|
|
29
|
+
// Handle server process events
|
|
30
|
+
server.on('error', (err) => {
|
|
31
|
+
console.error('Failed to start server:', err);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
});
|
|
34
|
+
server.on('exit', (code) => {
|
|
35
|
+
if (code !== 0) {
|
|
36
|
+
console.error(`Server process exited with code ${code}`);
|
|
37
|
+
}
|
|
38
|
+
process.exit(code || 0);
|
|
39
|
+
});
|
|
40
|
+
// Handle termination signals
|
|
41
|
+
process.on('SIGINT', () => {
|
|
42
|
+
console.log('\nShutting down ezPM2GUI...');
|
|
43
|
+
server.kill();
|
|
44
|
+
});
|
|
45
|
+
process.on('SIGTERM', () => {
|
|
46
|
+
console.log('\nShutting down ezPM2GUI...');
|
|
47
|
+
server.kill();
|
|
48
|
+
});
|
package/bin/ezpm2gui.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn, ChildProcess } from 'child_process';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
|
|
6
|
+
// Determine the path to the server executable
|
|
7
|
+
const serverPath = path.join(__dirname, '../dist/server/index.js');
|
|
8
|
+
|
|
9
|
+
// Check if the server file exists
|
|
10
|
+
if (!fs.existsSync(serverPath)) {
|
|
11
|
+
console.error('Error: Server executable not found. Please make sure the package is built correctly.');
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Start the server
|
|
16
|
+
const server: ChildProcess = spawn('node', [serverPath], { stdio: 'inherit' });
|
|
17
|
+
|
|
18
|
+
// Log startup message
|
|
19
|
+
console.log('\x1b[36m%s\x1b[0m', `
|
|
20
|
+
╔════════════════════════════════════╗
|
|
21
|
+
║ ezPM2GUI Started ║
|
|
22
|
+
╚════════════════════════════════════╝
|
|
23
|
+
|
|
24
|
+
Web interface available at: \x1b[1mhttp://localhost:3001\x1b[0m
|
|
25
|
+
|
|
26
|
+
Press Ctrl+C to stop the server.
|
|
27
|
+
`);
|
|
28
|
+
|
|
29
|
+
// Handle server process events
|
|
30
|
+
server.on('error', (err: Error) => {
|
|
31
|
+
console.error('Failed to start server:', err);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
server.on('exit', (code: number | null) => {
|
|
36
|
+
if (code !== 0) {
|
|
37
|
+
console.error(`Server process exited with code ${code}`);
|
|
38
|
+
}
|
|
39
|
+
process.exit(code || 0);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Handle termination signals
|
|
43
|
+
process.on('SIGINT', () => {
|
|
44
|
+
console.log('\nShutting down ezPM2GUI...');
|
|
45
|
+
server.kill();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
process.on('SIGTERM', () => {
|
|
49
|
+
console.log('\nShutting down ezPM2GUI...');
|
|
50
|
+
server.kill();
|
|
51
|
+
});
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
6
9
|
const ecosystemConfig = `
|
|
7
10
|
module.exports = {
|
|
8
11
|
apps : [
|
|
@@ -38,20 +41,19 @@ module.exports = {
|
|
|
38
41
|
}
|
|
39
42
|
]
|
|
40
43
|
}
|
|
41
|
-
`;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
44
|
+
`;
|
|
45
|
+
// Get the output path
|
|
46
|
+
const outputPath = process.argv[2] || 'ecosystem.config.js';
|
|
47
|
+
const fullPath = path_1.default.resolve(process.cwd(), outputPath);
|
|
48
|
+
try {
|
|
49
|
+
// Write file
|
|
50
|
+
fs_1.default.writeFileSync(fullPath, ecosystemConfig);
|
|
51
|
+
console.log(`PM2 ecosystem file generated at: ${fullPath}`);
|
|
52
|
+
console.log('\nTo start your PM2 processes with this configuration:');
|
|
53
|
+
console.log(' pm2 start ecosystem.config.js');
|
|
54
|
+
console.log('\nTo monitor your processes with ezPM2GUI:');
|
|
55
|
+
console.log(' ezpm2gui');
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
console.error('Error generating ecosystem file:', error);
|
|
59
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
const ecosystemConfig = `
|
|
6
|
+
module.exports = {
|
|
7
|
+
apps : [
|
|
8
|
+
{
|
|
9
|
+
name: "my-api",
|
|
10
|
+
script: "./api/index.js",
|
|
11
|
+
instances: 2,
|
|
12
|
+
exec_mode: "cluster",
|
|
13
|
+
watch: false,
|
|
14
|
+
env: {
|
|
15
|
+
NODE_ENV: "production",
|
|
16
|
+
PORT: 3000
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: "worker",
|
|
21
|
+
script: "./workers/queue-processor.js",
|
|
22
|
+
instances: 1,
|
|
23
|
+
watch: false,
|
|
24
|
+
env: {
|
|
25
|
+
NODE_ENV: "production"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "cron-job",
|
|
30
|
+
script: "./cron/scheduler.js",
|
|
31
|
+
instances: 1,
|
|
32
|
+
watch: false,
|
|
33
|
+
cron_restart: "0 0 * * *",
|
|
34
|
+
env: {
|
|
35
|
+
NODE_ENV: "production"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
// Get the output path
|
|
43
|
+
const outputPath: string = process.argv[2] || 'ecosystem.config.js';
|
|
44
|
+
const fullPath: string = path.resolve(process.cwd(), outputPath);
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
// Write file
|
|
48
|
+
fs.writeFileSync(fullPath, ecosystemConfig);
|
|
49
|
+
console.log(`PM2 ecosystem file generated at: ${fullPath}`);
|
|
50
|
+
console.log('\nTo start your PM2 processes with this configuration:');
|
|
51
|
+
console.log(' pm2 start ecosystem.config.js');
|
|
52
|
+
console.log('\nTo monitor your processes with ezPM2GUI:');
|
|
53
|
+
console.log(' ezpm2gui');
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error('Error generating ecosystem file:', error);
|
|
56
|
+
}
|