-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginxConfigurator.js
More file actions
36 lines (31 loc) · 969 Bytes
/
Copy pathnginxConfigurator.js
File metadata and controls
36 lines (31 loc) · 969 Bytes
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
/**
* dité: Process based shared web hosting
*
* nginxConfigurator.js
* NGINX Configuration per Application
*
* @author Putu Wiramaswara Widya <wiramaswara11@mhs.if.its.ac.id>
*/
var fs = require('fs');
var childProcess = require('child_process');
module.exports.createNginxConfig = function(port, cname, callback, callbackError) {
var configurationString = "server {\
listen 80;\
server_name " + cname + ";\
access_log /var/log/nginx/" + cname + ";\
location / {\
proxy_pass http://127.0.0.1:" + port + "/;\
}\
}";
// Then write it bro
fs.writeFile('/etc/nginx/sites-enabled/' + cname, configurationString, function(err) {
if(err) callbackError();
else callback();
});
};
module.exports.reloadNginx = function(callback) {
var nginx = childProcess.spawn('service', ['nginx', 'reload']);
nginx.on('exit', function() {
if(callback) callback();
});
}