Сервер уходит в тайм-аут при выполнении exec

Нужно выполнить команду через exec при поступлении запроса с сервера. Всё прекрасно. Команда выполняется, но сервер не выдаёт ответ. Падает в тайм-аут. В чём тут проблема?

const ejs = require('ejs');
const http = require('http');
const { exec } = require('child_process').execSync;

var content = fs.readFileSync('public/index.html', 'utf-8');
var compiled = ejs.compile(content);

const server = http.createServer((req, res) => {
    res.writeHead(200, { 'Content-Type': 'application/json' })
    exec_comm("git pull")
    res.end(compiled({});
});
server.listen(port, () => 'Server up');

function exec_comm(comm) {
    exec(comm);
}

Ответы (0 шт):