El servicio de Nginx ahora se inicia desde Gulp. Añadido alias de instalacion "gulp i".
This commit is contained in:
parent
d24058bab1
commit
692a226b69
|
@ -19,3 +19,4 @@ rules:
|
||||||
no-eq-null: 0
|
no-eq-null: 0
|
||||||
no-console: 0
|
no-console: 0
|
||||||
no-warning-comments: 0
|
no-warning-comments: 0
|
||||||
|
no-empty: 0
|
||||||
|
|
50
gulpfile.js
50
gulpfile.js
|
@ -101,6 +101,9 @@ gulp.task('install', () => {
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Gulp install alias
|
||||||
|
gulp.task('i', ['install']);
|
||||||
|
|
||||||
// Deployment
|
// Deployment
|
||||||
|
|
||||||
gulp.task('build', ['clean'], () => {
|
gulp.task('build', ['clean'], () => {
|
||||||
|
@ -141,15 +144,50 @@ gulp.task('docker-compose', async () => {
|
||||||
|
|
||||||
// Nginx & services
|
// Nginx & services
|
||||||
|
|
||||||
gulp.task('nginx', ['nginx-conf'], callback => {
|
let nginxConf = 'temp/nginx.conf';
|
||||||
let command = isWindows ? 'start.cmd' : 'start.sh';
|
let nginxTemp = `${nginxDir}/temp`;
|
||||||
command = path.join(`${nginxDir}/${command}`);
|
|
||||||
exec(command, (err, stdout, stderr) => {
|
async function nginxGetBin() {
|
||||||
// if (stderr) console.log(stderr);
|
if (isWindows)
|
||||||
callback(err);
|
return 'nginx';
|
||||||
|
try {
|
||||||
|
let nginxBin = '/usr/sbin/nginx';
|
||||||
|
await fs.stat(nginxBin);
|
||||||
|
return nginxBin;
|
||||||
|
} catch (e) {
|
||||||
|
return 'nginx';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gulp.task('nginx', ['nginx-stop'], async () => {
|
||||||
|
let nginxBin = await nginxGetBin();
|
||||||
|
|
||||||
|
if (isWindows)
|
||||||
|
nginxBin = `start /B ${nginxBin}`;
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
exec(`${nginxBin} -c "${nginxConf}" -p "${nginxDir}"`, err => {
|
||||||
|
if (err) return reject(err);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gulp.task('nginx-stop', ['nginx-conf'], async () => {
|
||||||
|
try {
|
||||||
|
let nginxBin = await nginxGetBin();
|
||||||
|
await fs.stat(`${nginxTemp}/nginx.pid`);
|
||||||
|
let command = `${nginxBin} -c "${nginxConf}" -p "${nginxDir}" -s stop`;
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
exec(command, err => {
|
||||||
|
if (err) return reject(err);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} catch (e) {}
|
||||||
|
});
|
||||||
|
|
||||||
gulp.task('nginx-conf', async () => {
|
gulp.task('nginx-conf', async () => {
|
||||||
const mustache = require('mustache');
|
const mustache = require('mustache');
|
||||||
|
|
||||||
|
|
|
@ -244,7 +244,7 @@
|
||||||
"aproba": {
|
"aproba": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
|
||||||
"integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==",
|
"integrity": "sha1-aALmJk79GMeQobDVF/DyYnvyyUo=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"archy": {
|
"archy": {
|
||||||
|
@ -10103,7 +10103,7 @@
|
||||||
"karma-chrome-launcher": {
|
"karma-chrome-launcher": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz",
|
||||||
"integrity": "sha512-uf/ZVpAabDBPvdPdveyk1EPgbnloPvFFGgmRhYLTDH7gEB4nZdSBk8yTU47w1g/drLSx5uMOkjKk7IWKfWg/+w==",
|
"integrity": "sha1-zxudBxNswY/iOTJ9JGVMPbw2is8=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"fs-access": "1.0.1",
|
"fs-access": "1.0.1",
|
||||||
|
@ -10134,7 +10134,7 @@
|
||||||
"karma-webpack": {
|
"karma-webpack": {
|
||||||
"version": "2.0.9",
|
"version": "2.0.9",
|
||||||
"resolved": "https://registry.npmjs.org/karma-webpack/-/karma-webpack-2.0.9.tgz",
|
"resolved": "https://registry.npmjs.org/karma-webpack/-/karma-webpack-2.0.9.tgz",
|
||||||
"integrity": "sha512-F1j3IG/XhiMzcunAXbWXH95uizjzr3WdTzmVWlta8xqxcCtAu9FByCb4sccIMxaVFAefpgnUW9KlCo0oLvIX6A==",
|
"integrity": "sha1-YciAkffdkQY1E0wDKyZqRlr/tX8=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"async": "0.9.2",
|
"async": "0.9.2",
|
||||||
|
@ -11183,7 +11183,7 @@
|
||||||
"node-sass": {
|
"node-sass": {
|
||||||
"version": "4.7.2",
|
"version": "4.7.2",
|
||||||
"resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.7.2.tgz",
|
"resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.7.2.tgz",
|
||||||
"integrity": "sha512-CaV+wLqZ7//Jdom5aUFCpGNoECd7BbNhjuwdsX/LkXBrHl8eb1Wjw4HvWqcFvhr5KuNgAk8i/myf/MQ1YYeroA==",
|
"integrity": "sha1-k2Z3i6FGnrAUOKnoWS9CYry2eU4=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"async-foreach": "0.1.3",
|
"async-foreach": "0.1.3",
|
||||||
|
@ -11401,7 +11401,7 @@
|
||||||
"npmlog": {
|
"npmlog": {
|
||||||
"version": "4.1.2",
|
"version": "4.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz",
|
||||||
"integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==",
|
"integrity": "sha1-CKfyqL9zRgR3mp76StXMcXq7lUs=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"are-we-there-yet": "1.1.4",
|
"are-we-there-yet": "1.1.4",
|
||||||
|
@ -15164,7 +15164,7 @@
|
||||||
"wide-align": {
|
"wide-align": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz",
|
||||||
"integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==",
|
"integrity": "sha1-Vx4PGwYEY268DfwhsDObvjE0FxA=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"string-width": "1.0.2"
|
"string-width": "1.0.2"
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
@echo off
|
|
||||||
|
|
||||||
set nginxDir=%~dp0
|
|
||||||
set nginxTemp=%nginxDir%\temp
|
|
||||||
set nginxConf=temp\nginx.conf
|
|
||||||
|
|
||||||
if "%1"=="" goto caseStart
|
|
||||||
if "%1"=="start" goto caseStart
|
|
||||||
if "%1"=="stop" goto caseStop
|
|
||||||
goto caseUsage
|
|
||||||
|
|
||||||
:caseStart
|
|
||||||
call "%0" stop
|
|
||||||
echo Starting nginx.
|
|
||||||
if not exist "%nginxTemp%" (mkdir "%nginxTemp%")
|
|
||||||
start /I nginx -c "%nginxConf%" -p "%nginxDir%"
|
|
||||||
goto caseEnd
|
|
||||||
|
|
||||||
:caseStop
|
|
||||||
echo Stoping nginx.
|
|
||||||
if exist "%nginxTemp%\nginx.pid" (nginx -c "%nginxConf%" -p "%nginxDir%" -s stop)
|
|
||||||
goto caseEnd
|
|
||||||
|
|
||||||
:caseUsage
|
|
||||||
echo "Usage: %0 [start|stop]"
|
|
||||||
|
|
||||||
:caseEnd
|
|
|
@ -1,28 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
nginxDir="$(dirname $0)"
|
|
||||||
nginxTemp="$nginxDir/temp"
|
|
||||||
nginxConf="temp/nginx.conf"
|
|
||||||
nginxBin="/usr/sbin/nginx"
|
|
||||||
|
|
||||||
if [ ! -f $nginxBin ]; then
|
|
||||||
nginxBin="nginx"
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start|"")
|
|
||||||
$0 stop
|
|
||||||
echo "Starting nginx."
|
|
||||||
mkdir -p "$nginxTemp"
|
|
||||||
"$nginxBin" -c "$nginxConf" -p "$nginxDir"
|
|
||||||
;;
|
|
||||||
stop)
|
|
||||||
echo "Stoping nginx."
|
|
||||||
if [ -f "$nginxTemp/nginx.pid" ]; then
|
|
||||||
"$nginxBin" -c "$nginxConf" -p "$nginxDir" -s stop
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Usage: `basename "$0"` [start|stop]"
|
|
||||||
exit 1
|
|
||||||
esac
|
|
Loading…
Reference in New Issue