added git auto update

This commit is contained in:
Baipyrus 2022-05-19 16:53:26 +02:00
parent 7fb6a7cd73
commit e82e19040a

View File

@ -3,6 +3,7 @@ const port = 3000;
const http = require('http');
const express = require('express');
const socketio = require('socket.io');
const { exec } = require('child_process');
const app = express();
const clientPath = __dirname+'/../client';
@ -12,6 +13,17 @@ app.use(express.static(clientPath));
const server = http.createServer(app);
const io = socketio(server);
app.post('/receiveUpdate', (req, res) => {
res.status(200).json({success:true});
exec(`sh ${__dirname}/../gitUpdate.sh`, (error, stdout, stderr) => {
console.log(stdout);
console.error(stderr);
if (error !== null) {
console.error(`exec error: ${error}`);
}
});
});
server.on('error', err => {
console.error('Server error:', err);
});