Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] 🐛 fix local installation #369

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/commands/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class RunCommand extends Command {

this.child.on('message', (message) => {
if (message.started) {
instance.process.success();
instance.process.success({pid: this.child.pid});
return;
}

Expand Down
14 changes: 6 additions & 8 deletions lib/utils/local-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const fs = require('fs-extra');
const path = require('path');
const fkill = require('fkill');
const extend = require('lodash/extend');
const spawn = require('child_process').spawn;
const assign = require('lodash/assign');
const isRunning = require('is-running');
Expand Down Expand Up @@ -40,13 +41,9 @@ class LocalProcess extends ProcessManager {
env: assign({}, process.env, {NODE_ENV: environment})
});

// Stick the pid into the pidfile so we can stop the process later
fs.writeFileSync(path.join(cwd, PID_FILE), cp.pid);

cp.on('error', reject);

cp.on('exit', (code) => {
fs.removeSync(path.join(cwd, PID_FILE));
reject(new errors.GhostError(`Ghost process exited with code: ${code}`));
});

Expand All @@ -59,11 +56,11 @@ class LocalProcess extends ProcessManager {
// Wait until Ghost tells us that it's started correctly, then resolve
cp.on('message', (msg) => {
if (msg.error) {
fs.removeSync(path.join(cwd, PID_FILE));

return reject(new errors.GhostError(msg));
}

fs.writeFileSync(path.join(cwd, PID_FILE), msg && msg.pid ? msg.pid : cp.pid);

if (msg.started) {
cp.disconnect();
cp.unref();
Expand Down Expand Up @@ -113,8 +110,9 @@ class LocalProcess extends ProcessManager {
* @method success
* @public
*/
success() {
if (process.send) {process.send({started: true});}
success(options) {
options = options || {};
if (process.send) {process.send(extend({started: true}, options));}
}

/**
Expand Down