Muthu Kumar
7 years ago
5 changed files with 64 additions and 40 deletions
@ -1,18 +1,27 @@ |
|||||
var fs = require('fs-extra') |
var fs = require('fs-extra') |
||||
|
var shell = require('shelljs') |
||||
|
var npath = require('../util/nginxPath') |
||||
|
var conf = require('../util/nginxConf') |
||||
|
|
||||
|
var { EOL } = require('os'); |
||||
|
|
||||
function createStaticServer(domain, outPort = 80) { |
function createStaticServer(domain, outPort = 80) { |
||||
fs.outputFileSync("/test.txt", |
fs.outputFileSync((conf(npath.availableSites(), domain)), |
||||
"server {" + "\n" + |
"server {" + EOL + |
||||
" listen " + outPort + ";" + "\n" + |
" listen " + outPort + ";" + EOL + |
||||
" listen [::]:" + outPort + ";" + "\n" + |
" listen [::]:" + outPort + ";" + EOL + |
||||
" root /var/www/" + domain + ";" + "\n" + |
" root /var/www/" + domain + ";" + EOL + |
||||
" index index.html index.htm;" + "\n" + |
" index index.html index.htm;" + EOL + |
||||
"" + "\n" + |
"" + EOL + |
||||
" server_name " + domain + "\n" + |
" server_name " + domain + EOL + |
||||
" location / {" + "\n" + |
" location / {" + EOL + |
||||
" try_files $uri $uri/ =404;" + |
" try_files $uri $uri/ =404;" + EOL + |
||||
|
" }" + EOL + |
||||
"}" |
"}" |
||||
) |
) |
||||
|
shell.mkdir('-p', npath.enabledSites()) |
||||
|
shell.ln('-sf', conf(npath.availableSites(), domain), conf(npath.enabledSites(), domain)) |
||||
|
shell.ln('-sf', ".", "/var/www" + domain) |
||||
} |
} |
||||
|
|
||||
module.exports = createStaticServer |
module.exports = createStaticServer |
@ -0,0 +1,6 @@ |
|||||
|
function parseToInt(inputString) { |
||||
|
var parsing = /^\d+$/.exec(inputString); |
||||
|
return (parsing || [])[0]; |
||||
|
} |
||||
|
|
||||
|
module.exports = parseToInt; |
Loading…
Reference in new issue