Skip to content

Instantly share code, notes, and snippets.

@ryanbekabe
Created August 5, 2020 04:19
Show Gist options
  • Save ryanbekabe/1e916ad161261b1963636a5b433eaca5 to your computer and use it in GitHub Desktop.
Save ryanbekabe/1e916ad161261b1963636a5b433eaca5 to your computer and use it in GitHub Desktop.
NodeJS Reload Apache
//node reload_apache.js
//Penerapan dari KSKK E-Learning Madrasah Generator: https://bekabe.my.id/
//Under: IDC (I Don't Care) License, karena setiap yang terpublik adalah untuk publik, dan jika tidak ingin terpublik, tidak usah dipublik
const http = require('http');
const hostname = 'hanyajasa.com';
const port = 8080;
const { exec } = require("child_process");
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Reload Apache. Sub Domain Anda sudah berhasil dibuat dan aktif.');
// exec("ls -lath", (error, stdout, stderr) => {
exec("service apache2 reload", (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.mssage}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment