Add self-updating to the code!

This commit is contained in:
youngchief btw ツ 2020-12-09 15:57:36 -08:00 committed by GitHub
parent df6750717f
commit fb1bb8af89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -11,6 +11,7 @@ const express = require("express");
const app = express();
const httpProxy = require("http-proxy");
// var proxy = httpProxy.createProxyServer({});
const { exec } = require("child_process");
function miniCPU() {
// This function lowers memory, disk, and CPU on request
@ -32,3 +33,18 @@ app.get("/", function(req, res) {
});
app.listen(process.env.PORT);
setInterval(function() {
// Self-updating
exec("git pull && git fetch", (error, stdout, stderr) => {
if (error) {
console.log(`${error.message}`);
return;
}
if (stderr) {
console.log(`${stderr}`);
return;
}
console.log(`${stdout}`);
});
}, 60000)