javascript - Node & forever wont start -
ive installed node using:
sudo apt-get install node
then afterwards:
sudo npm install forever --global
now trying run server using
forever start server.js
nothing happens no error nothing:
root@socialserver:/var/www/socialapi# forever start server.js root@socialserver:/var/www/socialapi# node server.js root@socialserver:/var/www/socialapi#
so nothing happens :s
can tell me if im missing or have done wrong
im using ubuntu 14.04
server.js:
// base setup // ============================================================================= var express = require('express'), bodyparser = require('body-parser'); var app = express(); var router = express.router(); var es = require('express-sequelize'); var multer = require('multer'); var excel = require("exceljs"); var ex = require('xlsjs'); var stream = require('stream'); var fs = require('fs'); var xlsx = require('xlsx'); var async = require('async'); app.use(bodyparser.json()); app.use(bodyparser.urlencoded({ extended: true })); // ============================================================================= //secure app.all('/*', function (req, res, next) { // cors headers res.header("access-control-allow-origin", "*"); // restrict required domain res.header('access-control-allow-methods', 'get,put,post,delete,options'); // set custom headers cors res.header('access-control-allow-headers', 'content-type,accept,x-access-token,x-key'); if (req.method == 'options') { res.status(200).end(); } else { next(); } }); var env = app.get('local') == 'development' ? 'dev' : app.get('env'); var port = process.env.port || 8092; var sequelize = require('sequelize'); // db config var env = "local"; var config = require('./database.json')[env]; var password = config.password ? config.password : null; // initialize database connection var sequelize = new sequelize( config.database, config.user, config.password, { port: config.port, host: config.server, logging: console.log, define: { timestamps: false } } ); var user = {}; var done = {is_complete: false}; app.use(multer({ dest: './uploads/', rename: function (fieldname, filename) { return filename + date.now(); }, onfileuploadstart: function (file) { console.log(file.originalname + ' starting ...') }, onfileuploadcomplete: function (file) { //redirects request path } })); var auth = require('./auth.js')(express, sequelize, router); app.all('/api/*', [require('./middlewares/validaterequest')]); app.use('/', router); app.use(auth); //init models var user_model = require('./social_models/user/user_model')(express, sequelize, router, user, async); var family_model = require('./social_models/user/family')(express, sequelize, router, user, async); var post_model = require('./social_models/post/post')(express, sequelize, router, user, async); app.use(user_model); app.use(family_model); app.use(post_model); // if no route matched now, must 404 app.use(function (req, res, next) { var err = new error('not found'); err.status = 404; next(err); }); // start server app.listen(port); console.log('magic happens on port ' + port);
as others have said, whole point of forever daemonize node app , let run in background.
if check forever list
or top
, see instances have started. forever -h
tell different commands , options can use start , stop processes.
i suggest looking using node's native cluster
. haven't use forever long time, used less ideal in production environment, , although still marked unstable in official docs, cluster
has proven reliable , lightweight in experience far.
Comments
Post a Comment