Skip to content

Commit

Permalink
🐛 pass environment to process manager and set contentPath on start
Browse files Browse the repository at this point in the history
  • Loading branch information
acburdine committed Sep 20, 2016
1 parent fcc1229 commit 1bd6016
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
21 changes: 13 additions & 8 deletions lib/commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ module.exports = BaseCommand.extend({
var resolveProcessManager = require('../process').resolve,
Config = require('../utils/config'),
Promise = require('bluebird'),
env = {},
path = require('path'),
self = this,
environment, config, pm, cliConfig;

options = options || {};
env.NODE_ENV = environment = (options.production || !options.development) ? 'production' : 'development';
environment = (options.production || !options.development) ? 'production' : 'development';

config = new Config('config.' + environment + '.json');
cliConfig = new Config('.ghost-cli');
Expand All @@ -41,11 +42,15 @@ module.exports = BaseCommand.extend({

pm = resolveProcessManager(config);

return this.ui.run(
Promise.resolve(pm.start(process.cwd())),
'Starting Ghost instance'
).then(function () {
cliConfig.set('running', environment).save();
});
// TODO: rethink this
return this.runCommand('config', 'paths.contentPath', path.join(process.cwd(), 'content'), {})
.then(function () {
return self.ui.run(
Promise.resolve(pm.start(process.cwd(), environment)),
'Starting Ghost instance'
);
}).then(function () {
cliConfig.set('running', environment).save();
});
}
});
6 changes: 4 additions & 2 deletions lib/process/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ PID_FILE = '.ghostpid';
module.exports = BaseProcess.extend({
name: 'local',

start: function start(cwd) {
start: function start(cwd, environment) {
var fs = require('fs'),
path = require('path'),
assign = require('lodash/assign'),
spawn = require('child_process').spawn,
cp;

cp = spawn('node', ['current/index.js'], {
cwd: cwd,
detached: true,
stdio: 'ignore'
stdio: 'ignore',
env: assign({NODE_ENV: environment}, process.env)
});

fs.writeFileSync(path.join(cwd, PID_FILE), cp.pid);
Expand Down

0 comments on commit 1bd6016

Please sign in to comment.