-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (30 loc) · 1.01 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { initializeApp } from 'firebase/app';
import { getDatabase , ref, set , onValue } from "firebase/database";
import psList from "ps-list"
import express from 'express'
import { createServer } from "http"
import { Server } from "socket.io"
const app = express();
const server = createServer(app);
const socketio = new Server(server);
const firebaseConfig = {
apiKey: "AIzaSyBtnpZJVgkykipjGWBL9qYtJLOwO_91i1Y",
authDomain: "process-f6f96.firebaseapp.com",
databaseURL: "https://process-f6f96-default-rtdb.europe-west1.firebasedatabase.app",
storageBucket: "process-f6f96.appspot.com",
};
let list = await psList();
const doc_true = list.filter(i => i.cpu > 0,1);
const doc_false = list.filter(i => i.cpu === 0);
const appp = initializeApp(firebaseConfig);
const db = getDatabase(appp);
server.listen(3000 , ()=> {
console.log(" server is running ")
})
socketio.on('connection', (socket) => {
console.log('connected and ready')
set(ref(db, 'process/'), {
doc_true,
doc_false
});
})