@drocketxx/pm2me 1.1.0 → 1.1.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.
Files changed (3) hide show
  1. package/README.md +53 -160
  2. package/bin/pm2me.js +15 -11
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -10,6 +10,38 @@ PM2Me lets you **deploy apps directly from a GitHub repository**, manage PM2 pro
10
10
 
11
11
  ---
12
12
 
13
+ ## 🚀 Quick Start (Global Install)
14
+
15
+ The easiest way to use PM2Me is to install it globally via npm:
16
+
17
+ ```bash
18
+ # 1. Install globally
19
+ npm install -g @drocketxx/pm2me
20
+
21
+ # 2. Run the server
22
+ pm2me
23
+ ```
24
+
25
+ Open your browser at: **http://localhost:12345**
26
+
27
+ ---
28
+
29
+ ## 🛠️ Running as a Background Service
30
+
31
+ If you want PM2Me to run in the background and start automatically on system boot, use the built-in `service` command:
32
+
33
+ ```bash
34
+ # Install as a background service (using PM2)
35
+ pm2me service install
36
+
37
+ # To remove the background service
38
+ pm2me service uninstall
39
+ ```
40
+
41
+ > **Note:** The `service install` command will register PM2Me as `pm2me-server` in PM2 and attempt to set up system startup.
42
+
43
+ ---
44
+
13
45
  ## ✨ Features
14
46
 
15
47
  | Feature | Details |
@@ -45,188 +77,49 @@ PM2Me lets you **deploy apps directly from a GitHub repository**, manage PM2 pro
45
77
 
46
78
  ---
47
79
 
48
- ## 🚀 Getting Started
49
-
50
- ### Prerequisites
51
- - [Node.js](https://nodejs.org/) >= 18
52
- - [PM2](https://pm2.keymetrics.io/) installed globally: `npm install -g pm2`
53
- - [Git](https://git-scm.com/) installed and accessible in `PATH`
54
-
55
- ### Installation & Running (Recommended with PM2)
56
-
57
- ```bash
58
- # 1. Clone the repository
59
- git clone https://github.com/drocketxx/PM2Me.git
60
- cd PM2Me
61
-
62
- # 2. Install all dependencies (frontend + backend)
63
- npm run install:all
64
-
65
- # 3. Build the frontend
66
- npm run build
67
-
68
- # 4. Start PM2Me with PM2 ✅ Recommended
69
- cd backend
70
- pm2 start app.js --name pm2me
71
-
72
- # 5. Auto-start on system reboot
73
- pm2 save
74
- pm2 startup
75
- ```
76
-
77
- Open your browser at: **http://localhost:12345**
78
-
79
- > 💡 **Useful PM2 commands:**
80
- > ```bash
81
- > pm2 status # Check PM2Me status
82
- > pm2 logs pm2me # View PM2Me logs
83
- > pm2 restart pm2me # Restart PM2Me
84
- > pm2 stop pm2me # Stop PM2Me
85
- > ```
86
-
87
- **Development mode** (nodemon auto-restart):
88
- ```bash
89
- cd /path/to/PM2Me
90
- npm run dev
91
- ```
92
-
93
- ---
94
-
95
- ## 🔐 Default Login & Password Management
96
-
97
- On first run, **no password is set**. Use the CLI to set one:
80
+ ## 🔐 Setup & Security
98
81
 
99
- ```bash
100
- # Set or change admin password
101
- npm run pw -- <your_password>
102
-
103
- # Example
104
- npm run pw -- mySecretPass123
105
- ```
82
+ ### First Run
83
+ On your first run, PM2Me will guide you through a **Setup Wizard** to configure your apps storage path and set your admin password.
106
84
 
107
- > You can also run it directly from the `backend/` folder:
108
- > ```bash
109
- > cd backend && node scripts/change-password.js mySecretPass123
110
- > ```
111
- >
112
- > The password is stored as a **bcrypt hash** (12 rounds) in `backend/db/database.json`.
113
-
114
- ---
115
-
116
- ## 🔗 GitHub Webhook Setup
117
-
118
- PM2Me supports automatic deployments triggered by `git push`. Here's how to enable it:
85
+ ### Data Storage
86
+ - **Database:** Stored in `~/.pm2me/database.json`
87
+ - **Cloned Apps:** Default to `~/.pm2me/apps/` (User configurable)
119
88
 
89
+ ### GitHub Webhooks
120
90
  1. Go to your GitHub repository → **Settings** → **Webhooks** → **Add webhook**
121
91
  2. Set **Payload URL** to: `http://your-server-ip:12345/api/webhook`
122
92
  3. Set **Content type** to: **`application/json`** ⚠️
123
- 4. Set **Secret** from the Settings page in PM2Me (generate one if needed)
93
+ 4. Set **Secret** from the Settings page in PM2Me
124
94
  5. Select **Just the push event**
125
- 6. Click **Add webhook**
126
-
127
- PM2Me will automatically re-deploy any matching app (matched by repo URL + branch) on each push.
128
-
129
- > **Webhook History** (last 50 events) is displayed on the Settings page in real-time.
130
-
131
- ---
132
-
133
- ## 📂 Project Structure
134
-
135
- ```
136
- PM2Me/
137
- ├── backend/
138
- │ ├── app.js # Express server + Socket.IO setup
139
- │ ├── db/
140
- │ │ ├── index.js # LowDB initialization
141
- │ │ └── database.json # App data, settings, webhook logs
142
- │ ├── routes/
143
- │ │ ├── api.js # Main API routes
144
- │ │ └── auth.js # Login / JWT auth
145
- │ ├── services/
146
- │ │ ├── gitService.js # Git clone/pull operations
147
- │ │ ├── pm2Service.js # PM2 process management
148
- │ │ ├── systemService.js# CPU / RAM / Disk / Network stats
149
- │ │ └── notificationService.js # Discord & Telegram alerts
150
- │ ├── scripts/
151
- │ │ └── change-password.js # CLI tool to change admin password
152
- │ └── public/ # Built Vue frontend (served statically)
153
- ├── frontend/
154
- │ ├── src/
155
- │ │ ├── views/
156
- │ │ │ ├── Dashboard.vue # Main app dashboard
157
- │ │ │ ├── Settings.vue # Settings & webhook history
158
- │ │ │ └── Login.vue # Auth page
159
- │ │ ├── components/
160
- │ │ │ ├── DeployModal.vue # New/Edit app deployment modal
161
- │ │ │ ├── LogViewer.vue # Real-time log stream
162
- │ │ │ └── ServerStats.vue # CPU/RAM/Network widget
163
- │ │ ├── router/ # Vue Router config
164
- │ │ └── App.vue # Nav layout
165
- │ └── vite.config.js
166
- ├── apps/ # Cloned app repos live here
167
- └── package.json # Root scripts (dev, build, pw)
168
- ```
169
-
170
- ---
171
-
172
- ## 📝 Available Scripts
173
-
174
- Run these from the **root** `PM2Me/` directory:
175
-
176
- | Command | Description |
177
- |---|---|
178
- | `npm run dev` | Build frontend & start backend dev server |
179
- | `npm run build` | Build frontend only |
180
- | `npm run pw -- <password>` | Change admin password |
181
- | `npm run install:all` | Install all dependencies (root + frontend + backend) |
182
95
 
183
96
  ---
184
97
 
185
- ## 📡 API Overview
186
-
187
- | Method | Endpoint | Description |
188
- |---|---|---|
189
- | `POST` | `/api/auth/login` | Login, returns JWT token |
190
- | `GET` | `/api/pm2/list` | List all PM2 processes |
191
- | `POST` | `/api/pm2/:action` | PM2 action: start/stop/restart/delete |
192
- | `GET` | `/api/apps` | List all deployed apps (DB) |
193
- | `POST` | `/api/apps` | Register a new app |
194
- | `PUT` | `/api/apps/:id` | Update app config |
195
- | `DELETE` | `/api/apps/:id` | Delete app from DB |
196
- | `POST` | `/api/apps/:id/deploy` | Trigger deployment |
197
- | `GET` | `/api/apps/:id/sync-status` | Check if branch is behind remote |
198
- | `GET` | `/api/settings` | Get current settings |
199
- | `POST` | `/api/settings` | Save settings |
200
- | `GET` | `/api/settings/webhook-logs` | Get last 50 webhook events |
201
- | `POST` | `/api/webhook` | GitHub Webhook receiver |
202
- | `GET` | `/api/system/stats` | Server system stats |
98
+ ## 🛠️ Manual Installation (For Developers)
203
99
 
204
- ---
100
+ If you want to contribute or run from source:
205
101
 
206
- ## 📦 Deployment (Production)
102
+ ```bash
103
+ # 1. Clone the repository
104
+ git clone https://github.com/drocketxx/PM2Me.git
105
+ cd PM2Me
207
106
 
208
- For production, it's recommended to run the PM2Me backend itself with PM2:
107
+ # 2. Install all dependencies
108
+ npm run install:all
209
109
 
210
- ```bash
211
- # Build the frontend
110
+ # 3. Build the frontend
212
111
  npm run build
213
112
 
214
- # Start with PM2
215
- cd backend
216
- pm2 start app.js --name pm2me
217
-
218
- # Save and set to auto-restart on reboot
219
- pm2 save
220
- pm2 startup
113
+ # 4. Start in development mode
114
+ npm run dev
221
115
  ```
222
116
 
223
117
  ---
224
118
 
225
119
  ## 🛡 Security Notes
226
120
 
227
- - Change the default admin password immediately on first run using `npm run pw`.
228
- - Set a strong `JWT_SECRET` in your `.env` file.
229
- - Always set a **Webhook Secret** to prevent unauthorized deploys.
121
+ - Set a strong admin password during the setup wizard.
122
+ - Always use a **Webhook Secret** to prevent unauthorized deployment triggers.
230
123
  - Consider putting PM2Me behind a reverse proxy (e.g., Nginx) with HTTPS in production.
231
124
 
232
125
  ---
package/bin/pm2me.js CHANGED
@@ -25,8 +25,7 @@ if (args[0] === 'service') {
25
25
  if (action === 'install') {
26
26
  console.log('[pm2me] Installing background service...');
27
27
  try {
28
- // 1. Start pm2me via PM2
29
- // We use the full path to the backend app.js
28
+ const isWindows = os.platform() === 'win32';
30
29
  const appPath = path.join(backendDir, 'app.js');
31
30
  const homeDir = path.join(os.homedir(), '.pm2me');
32
31
  const dbPath = path.join(homeDir, 'database.json');
@@ -34,20 +33,25 @@ if (args[0] === 'service') {
34
33
  console.log(`[pm2me] Starting via PM2 as 'pm2me-server'...`);
35
34
  execSync(`pm2 start "${appPath}" --name pm2me-server --env PM2ME_DB_PATH="${dbPath}"`, { stdio: 'inherit' });
36
35
 
37
- // 2. Save PM2 list
38
36
  console.log(`[pm2me] Saving PM2 process list...`);
39
37
  execSync(`pm2 save`, { stdio: 'inherit' });
40
38
 
41
- // 3. Optional: Startup (User needs to run this with sudo/admin usually, but we try)
42
- console.log(`[pm2me] Setting up boot startup...`);
43
- try {
44
- execSync(`pm2 startup`, { stdio: 'inherit' });
45
- console.log(`[pm2me] Done! If you see a command above, please copy and run it to finalize startup.`);
46
- } catch (e) {
47
- console.log(`[pm2me] 'pm2 startup' might need manual execution. Check instructions above.`);
39
+ if (isWindows) {
40
+ console.log(`\n[pm2me] 💡 Windows Info: 'pm2me-server' is now running in the background.`);
41
+ console.log(`[pm2me] To make it start automatically on Windows restart, we recommend using 'pm2-windows-startup':`);
42
+ console.log(` npm install -g pm2-windows-startup`);
43
+ console.log(` pm2-startup install`);
44
+ } else {
45
+ console.log(`[pm2me] Setting up boot startup...`);
46
+ try {
47
+ execSync(`pm2 startup`, { stdio: 'inherit' });
48
+ console.log(`[pm2me] Done! If you see a command above, please copy and run it to finalize startup.`);
49
+ } catch (e) {
50
+ console.log(`[pm2me] 'pm2 startup' might need manual execution. Check instructions above.`);
51
+ }
48
52
  }
49
53
 
50
- console.log(`[pm2me] Service installed successfully. Access your UI at http://localhost:12345`);
54
+ console.log(`\n[pm2me] Service installed successfully. Access your UI at http://localhost:12345`);
51
55
  process.exit(0);
52
56
  } catch (err) {
53
57
  console.error(`[pm2me] Failed to install service:`, err.message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drocketxx/pm2me",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "PM2 Deployment and Management System — Web UI for PM2 process management",
5
5
  "type": "module",
6
6
  "main": "backend/app.js",