Skip to content

Commit

Permalink
v1.0.0 and NODE_ENV processing fix (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
mchepelev authored and Railag committed Nov 2, 2018
1 parent 02503c9 commit 138c2bc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iofogcontroller",
"version": "0.9.5",
"version": "1.0.0",
"description": "ioFog Controller project for Eclipse IoFog @ iofog.org \\nCopyright (c) 2018 Edgeworx, Inc.",
"main": "./src/main.js",
"author": "Saeid Baghbidi",
Expand Down Expand Up @@ -37,6 +37,7 @@
"start": "NODE_ENV=production node ./src/main.js start",
"start-dev": "NODE_ENV=development node ./src/main.js start",
"build": "export NODE_ENV=production && cd src/sequelize && ../../node_modules/.bin/sequelize db:migrate && ../../node_modules/.bin/sequelize db:seed:all",
"postinstall": "export NODE_ENV=production && cd src/sequelize && ../../node_modules/.bin/sequelize db:migrate && ../../node_modules/.bin/sequelize db:seed:all",
"lint": "./node_modules/.bin/eslint \"**/*.js\""
},
"preferGlobal": true,
Expand Down
20 changes: 12 additions & 8 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,24 @@
*
*/

const daemonize = require('daemonize2')
const db = require('./sequelize/models')
const Cli = require('./cli')
const logger = require('./logger')
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = 'production'
}

const daemonize = require('daemonize2');
const db = require('./sequelize/models');
const Cli = require('./cli');
const logger = require('./logger');

function main() {
const daemon = daemonize.setup({
main: 'server.js',
name: 'iofog-controller',
pidfile: 'iofog-controller.pid',
silent: true,
})
});

const cli = new Cli()
const cli = new Cli();

daemon
.on('starting', () => {
Expand All @@ -46,7 +50,7 @@ function main() {
})
.on('error', (err) => {
logger.silly('iofog-controller failed to start: ' + err.message)
})
});

cli.run(daemon)
}
Expand All @@ -59,4 +63,4 @@ db.sequelize
.catch((err) => {
logger.silly('Unable to initialize the database.', err)
process.exit(1)
})
});

0 comments on commit 138c2bc

Please sign in to comment.