This repository was archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
50 lines (44 loc) · 1.26 KB
/
index.js
File metadata and controls
50 lines (44 loc) · 1.26 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
import fs from 'fs';
import db from './functions/database.js';
import setup from './functions/setup.js';
setup(db);
function createStatusFile() {
console.log("Criando arquivo...");
const panel = db.get('panel');
const wings = db.get('wings');
const lastSynced = db.get('lastSynced');
// Verificar se algum valor é undefined
if (panel === undefined || wings === undefined || lastSynced === undefined) {
console.log("Algum valor é indefinido. Tentando novamente em 10 segundos...");
setTimeout(createStatusFile, 10000); // Chama a função novamente após 10 segundos
return;
}
const data = {
"daemon": "0.9.999",
panel,
wings,
"sftp": "1.0.5",
"discord": "https://discord.gg/Wf8Eycz4Tq",
lastSynced
};
const json = JSON.stringify(data, null, 2);
fs.writeFile("status.json", json, (err) => {
if (err) {
console.error(err.message);
} else {
console.log("Arquivo criado com sucesso");
}
});
// Fechar o banco de dados após 2 segundos
setTimeout(function main() {
db.close((err) => {
if (err) {
console.error(err.message);
} else {
console.log('Banco de dados parado com sucesso');
}
});
}, 2000);
}
// Chama a função pela primeira vez
createStatusFile();