Skip to content

Commit 83c39b7

Browse files
committed
initial commit
0 parents  commit 83c39b7

77 files changed

Lines changed: 18633 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
# pm2.web - Process Monitoring and Management
2+
3+
pm2.web is a web-based application designed to monitor and manage processes running on your server using the PM2 process manager. With pm2.web, you can easily monitor your processes, control them with various actions, view logs, manage server functions, and even set up access controls for users.Easily install, deploy to Vercel, and utilize MongoDB Atlas to maintain a server with 0 open ports or host everything on-premise.
4+
5+
## Pages - Features
6+
7+
1. **Monitoring**
8+
![Index](assets/index.jpeg)
9+
2. **Process Management**
10+
![Process](assets/process.jpeg)
11+
3. **Server Management (Planned)**
12+
4. **Access Control**
13+
![Access Control](assets/user_adminstration.jpeg)
14+
5. **Settings**
15+
![Settings](assets/settings.jpeg)
16+
6. **Alert Setup (Planned)**
17+
18+
## Installation
19+
20+
To get started with pm2.web, follow these steps:
21+
22+
### Vercel & MongoDB Atlas
23+
24+
<details>
25+
<summary>Expand</summary>
26+
27+
#### MongoDB Atlas
28+
29+
1. Create a MongoDB Atlas account and create a new project.
30+
2. Create a new cluster and select the free tier.
31+
3. Create a new database user and save the username and password.
32+
4. Add your IP address to the IP Access List or through a CIDR block.
33+
34+
#### Vercel
35+
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/oxdev03/pm2.web&env=MONGO_URI&description=Process+Monitoring+and+Management&rootDirectory=dashboard)
36+
37+
1. Click the deploy button above and follow the instructions.
38+
39+
#### Backend
40+
[Follow the instructions here , On-Premise->Backend](#backend1)
41+
42+
</details>
43+
44+
### On-Premise
45+
46+
<details>
47+
<summary>Expand</summary>
48+
49+
1. Clone the repository to your server.
50+
51+
```bash
52+
git clone https://github.com/oxdev03/pm2.web.git
53+
```
54+
55+
#### Backend
56+
<a name="backend1"></a>
57+
58+
The Backend is a simple nodejs application that uses the pm2 BUS API to communicate and monitor pm2 process.
59+
It doesn't require any open ports, since it only saves data to the database and events like restart, stop, delete are relayed through the change stream of mongodb.
60+
61+
##### Requirements
62+
63+
- Nodejs v16
64+
- MongoDB Cluster
65+
- PM2
66+
67+
##### Installation
68+
69+
1. Install the dependencies
70+
71+
```bash
72+
cd backend
73+
npm install
74+
```
75+
76+
2. Create a `.env` file in the backend directory and add the following variables
77+
78+
```bash
79+
MONGO_URI=<MongoDB URI>
80+
```
81+
82+
3. Start the backend
83+
84+
```bash
85+
npm start
86+
```
87+
88+
#### Frontend
89+
90+
##### Requirements
91+
92+
- Open Port 3000 or 80,443 (if you use a reverse proxy)
93+
- Nodejs v16
94+
- MongoDB
95+
96+
##### Installation
97+
98+
1. Install the dependencies
99+
100+
```bash
101+
cd dashboard
102+
npm install
103+
```
104+
105+
2. Create a `.env` file in the dashboard directory and add the following variables
106+
107+
```bash
108+
MONGO_URI=<MongoDB URI>
109+
NEXTAUTH_URL=<Index URL of the dashboard eg. http://ip:3000>
110+
```
111+
112+
3. Build the frontend
113+
114+
```bash
115+
npm run build
116+
```
117+
118+
4. Start the frontend
119+
120+
```bash
121+
npm start
122+
```
123+
124+
</details>
125+
126+
## Usage
127+
128+
Once pm2.web is installed and running, you can perform the following actions:
129+
130+
- **Monitoring**:
131+
132+
- Monitor the status, resource usage, and health of your processes from the main dashboard.
133+
134+
- **Process**:
135+
136+
- Stop, restart, or delete processes from the process list page.
137+
- Access the logs generated by your processes.
138+
- View key metrics and graphs to assess the performance of your applications.
139+
- Pm2 Settings & Git Feature
140+
141+
- **Server Management (Planned)**:
142+
143+
- Control server-level functions such as shutdown or restart using the dedicated server management page.
144+
- Execute these actions securely without the need for direct server access.
145+
- View key metrics and graphs
146+
- Configure specific server settings (db log rotation , polling/update interval)
147+
148+
- **Access Control**:
149+
150+
- Manage user access and permissions through the access control settings.
151+
- Create user accounts, assign roles, and specify the level of access each user has to servers, processes, and application functions.
152+
153+
- **Settings**:
154+
155+
- Configure settings such as the update interval, log rotation, and more.
156+
157+
- **Alert Setup (Planned)**:
158+
- Configure alerts to receive notifications for specific actions.
159+
- Define alert rules based on events like shutdown, restart, or kill actions.
160+
161+
## Milestones (based on stars)
162+
163+
I have a lot of ideas for this project, but I don't have the time to implement them all due to my busy schedule. Nor the less the project will be maintained even if it doesn't reach the milestones.
164+
165+
- [x] 0 Stars - Active Maintenance/Bug Fixes
166+
- [] 20 Stars - Server Management
167+
- [] 50 Stars - Alert Setup
168+
- [] 100 Stars - Change Database to PostgreSQL for better performance
169+
- [] 150 Stars - Live Monitoring (Websocket)
170+
171+
## Contributing
172+
173+
Contributions to pm2.web are welcome! If you would like to contribute to the project, please follow these guidelines:
174+
175+
1. Fork the repository on GitHub.
176+
177+
2. Create a new branch from the `develop` branch to work on your changes.
178+
179+
3. Make your modifications and ensure they adhere to the project's coding standards.
180+
181+
4. Commit your changes with clear and descriptive commit messages.
182+
183+
5. Push your branch to your forked repository.
184+
185+
6. Submit a pull request to the `develop` branch of the main pm2.web repository.
186+
187+
## License
188+
189+
pm2.web is released under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html). For more information, please refer to the [LICENSE](LICENSE) file.
190+
191+
## Support
192+
193+
For any questions, issues, or feature requests, please refer to the project's GitHub repository: [github.com/oxdev03/pm2.web](https://github.com/oxdev03/pm2.web.git).
194+
195+
Open an issue and provide details about your inquiry, and the community or maintainers will assist you as soon as possible.
196+
197+
## Credits
198+
199+
pm2.web is built on the foundation of the PM2 process manager (BUS Api) ([pm2.keymetrics.io](https://pm2.keymetrics.io/)). We acknowledge and appreciate the PM2 team's efforts.
200+
201+
The pm2.web project is currently maintained and supported by a single developer.
202+
203+
## Disclaimer
204+
205+
pm2.web is not affiliated with or endorsed by PM2 or ([pm2.keymetrics.io](https://pm2.keymetrics.io/)). pm2.web is an independent project created by a third-party developer.

assets/index.jpeg

94.7 KB
Loading

assets/process.jpeg

66 KB
Loading

assets/settings.jpeg

78.8 KB
Loading

assets/user_adminstration.jpeg

71.8 KB
Loading

backend/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Dependency directory
7+
node_modules
8+
9+
# Environment
10+
.env
11+
12+
# Transpiled output
13+
dist

backend/handlers/captureLogs.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import pm2 from 'pm2';
2+
3+
import { Packet, QueuedLog } from '../types/handler.js';
4+
import censorMessage from '../utils/censorMessage.js';
5+
6+
class LogCapture {
7+
private queuedLogs: QueuedLog[] = [];
8+
9+
constructor() {}
10+
11+
capture(): void {
12+
pm2.launchBus((err, bus) => {
13+
bus.on('log:err', (packet: Packet) => {
14+
this.queuedLogs.push({
15+
id: packet.process.pm_id,
16+
type: 'error',
17+
message: censorMessage(`[${packet.process.name}] ${packet.data}`.replace(/\n$/, '')),
18+
createdAt: new Date(),
19+
});
20+
});
21+
22+
bus.on('log:out', (packet: Packet) => {
23+
this.queuedLogs.push({
24+
id: packet.process.pm_id,
25+
type: 'success',
26+
message: censorMessage(`[${packet.process.name}] ${packet.data}`.replace(/\n$/, '')),
27+
createdAt: new Date(),
28+
});
29+
});
30+
31+
bus.on('process:event', (packet: Packet) => {
32+
if (packet.event === 'online') {
33+
this.queuedLogs.push({
34+
id: packet.process.pm_id,
35+
type: 'info',
36+
message: `[${packet.process.name}] Process online`,
37+
createdAt: new Date(),
38+
});
39+
} else if (packet.event === 'exit') {
40+
this.queuedLogs.push({
41+
id: packet.process.pm_id,
42+
type: 'info',
43+
message: `[${packet.process.name}] Process offline`,
44+
createdAt: new Date(),
45+
});
46+
}
47+
});
48+
});
49+
}
50+
51+
clear(): QueuedLog[] {
52+
const shallowCopy = [...this.queuedLogs];
53+
this.queuedLogs = [];
54+
return shallowCopy;
55+
}
56+
}
57+
58+
export default LogCapture;

backend/handlers/connectDb.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import mongoose from 'mongoose';
2+
3+
const connectDb = (MONGO_URI: string | undefined) => {
4+
if (!MONGO_URI) {
5+
throw new Error('MONGO_URI is not defined');
6+
}
7+
mongoose
8+
.connect(MONGO_URI)
9+
.then(() => {
10+
console.log('[DATABASE] Connected');
11+
})
12+
.catch((err) => {
13+
console.error(err);
14+
});
15+
};
16+
17+
export default connectDb;

0 commit comments

Comments
 (0)