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

fix(systemd) improve systemd precheck error messages #628

Merged
merged 1 commit into from
Feb 6, 2018
Merged
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
11 changes: 9 additions & 2 deletions extensions/systemd/systemd.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const fs = require('fs');
const execa = require('execa');
const cli = require('../../lib');
const getUid = require('./get-uid');
const chalk = require('chalk');

class SystemdProcessManager extends cli.ProcessManager {
get systemdName() {
Expand Down Expand Up @@ -101,14 +102,20 @@ class SystemdProcessManager extends cli.ProcessManager {
const uid = getUid(this.instance.dir);

if (!uid) {
throw new cli.errors.SystemError('Systemd process manager has not been set up. Run `ghost setup linux-user systemd` and try again.')
throw new cli.errors.SystemError({
message: 'Systemd process manager has not been set up or is corrupted.',
help: `Run ${chalk.green('ghost setup linux-user systemd')} and try again.`
});
}

if (fs.existsSync(`/lib/systemd/system/${this.systemdName}.service`)) {
return;
}

throw new cli.errors.SystemError('Systemd process manager has not been set up. Run `ghost setup systemd` and try again.');
throw new cli.errors.SystemError({
message: 'Systemd process manager has not been set up or is corrupted.',
help: `Run ${chalk.green('ghost setup systemd')} and try again.`
});
}

static willRun() {
Expand Down
6 changes: 4 additions & 2 deletions extensions/systemd/test/systemd-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ describe('Unit: Systemd > Process Manager', function () {
expect(proxyOpts['./get-uid'].calledOnce).to.be.true;
expect(error).to.be.ok;
expect(error).to.be.instanceOf(errors.SystemError);
expect(error.message).to.match(/ghost setup linux-user systemd/);
expect(error.message).to.match(/Systemd process manager has not been set up or is corrupted./);
expect(error.options.help).to.match(/ghost setup linux-user systemd/);
}
});

Expand All @@ -337,7 +338,8 @@ describe('Unit: Systemd > Process Manager', function () {
expect(fsStub.calledOnce).to.be.true;
expect(error).to.be.ok;
expect(error).to.be.instanceOf(errors.SystemError);
expect(error.message).to.match(/ghost setup systemd/);
expect(error.message).to.match(/Systemd process manager has not been set up or is corrupted./);
expect(error.options.help).to.match(/ghost setup systemd/);
}
});
});
Expand Down