终端
hutber@hutber-ubuntu:/var/www/syndicated-sharing$ ps -s | grep node
1000 8949 0000000000000000 0000000000000000 0000000000001000 0000000000010002 S+ pts/11 0:00 sh -c node ./syndshare.js
1000 8950 0000000000000000 0000000000000000 0000000000001000 0000000188004202 Sl+ pts/11 0:00 node ./syndshare.js
1000 8978 0000000000000000 0000000000000000 0000000000000000 0000000000000000 S+ pts/20 0:00 grep --color=auto node
hutber@hutber-ubuntu:/var/www/syndicated-sharing$ sudo pkill node
hutber@hutber-ubuntu:/var/www/syndicated-sharing$ ps -s | grep node
1000 8938 0000000000000000 0000000000000000 0000000000000000 0000000000000000 S+ pts/20 0:00 grep --color=auto node
错误
hutber@hutber-ubuntu:/var/www/syndicated-sharing$ NODE_ENV=dev gulp dev
WARNING: NODE_ENV value of 'dev' did not match any deployment config file names.
WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
[16:06:17] Using gulpfile /var/www/syndicated-sharing/gulpfile.js
[16:06:17] Starting 'setWatch'...
[16:06:17] Finished 'setWatch' after 52 μs
[16:06:17] Starting 'sass'...
[16:06:17] Starting 'browser'...
[16:06:17] Finished 'browser' after 31 ms
[16:06:17] Starting 'js'...
[BS] Proxying: http://localhost:8801
[BS] Access URLs:
--------------------------------------
Local: http://localhost:4005
External: http://10.100.15.146:4005
--------------------------------------
UI: http://localhost:3002
UI External: http://10.100.15.146:3002
--------------------------------------
[BS] Watching files...
[16:06:17] Finished 'sass' after 152 ms
[16:06:17] Starting 'watch'...
[16:06:17] Finished 'watch' after 14 ms
[16:06:17] Finished 'js' after 173 ms
[16:06:17] Starting 'dev'...
[16:06:17] Finished 'dev' after 63 ms
[BS] File changed: dist/css/style.css
[16:06:17] [nodemon] 1.9.2
[16:06:17] [nodemon] to restart at any time, enter `rs`
[16:06:17] [nodemon] watching: *.*
[16:06:17] [nodemon] starting `node ./syndshare.js`
8801
METRIC ns="syndshare" name="start" port="8801"
events.js:154
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::8801
at Object.exports._errnoException (util.js:890:11)
at exports._exceptionWithHostPort (util.js:913:20)
at Server._listen2 (net.js:1231:14)
at listen (net.js:1267:10)
at Server.listen (net.js:1363:5)
at EventEmitter.listen (/var/www/syndicated-sharing/node_modules/express/lib/application.js:617:24)
at Object.<anonymous> (/var/www/syndicated-sharing/syndshare.js:31:5)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
Gulp / Node设置
//default
browserSync({
proxy: "localhost:"+config.port,
port: 4004,
open: false,
files: [
gulpConfig.paths.public + gulpConfig.paths.css + gulpConfig.filenames.css,
"./client/js/**/*.js",
"./index.html",
],
reloadDelay: 100
});
//browser.js
var gulp = require('gulp');
gulp.task('dev',['watch', 'js'], function () {
var nodemon = require('gulp-nodemon');
return nodemon({
script: './syndshare.js',
watch: './lib/'
, ext: 'js html'
, env: { 'NODE_ENV': 'development' }
}).on('start', function () {
console.log('MOL-fe-brexit has started');
}).on('quit', function () {
console.log('MOL-fe-brexit has quit');
}).on('restart', function (files) {
console.log('MOL-fe-brexit restarted due to: ', files);
});
});
Syndshare.js
var express = require("express");
//var https = require('https');
//var http = require('http');
//var fs = require('fs');
/* #Load configurations with npm config ----------------------------- */
var config = require('config');
/* #Set up App ------------------------------------------------------ */
var app = express();
/* #Express Setting ------------------------------------------------- */
require('./lib/express')(app, config);
/* #Routes ----------------------------------------------------------- */
require('./lib/routes')(app, config);
require('./lib/auth')(app, config);
app.listen(config.port, function () {
console.log( 'METRIC ns="syndshare" name="start" port="' + config.port + '"' );
});
process.on('exit', function () {
app.close && app.close();
});
process.on('SIGINT', function () {
process.exit(2);
});
无论我改变什么端口都不会运行。我想让服务器运行。