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] use systemd-notify for success and error calls #600

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
3 changes: 2 additions & 1 deletion extensions/systemd/ghost.service.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Description=Ghost systemd service for blog: <%= name %>
Documentation=https://docs.ghost.org

[Service]
Type=simple
Type=notify
NotifyAccess=all
WorkingDirectory=<%= dir %>
User=<%= user %>
Environment="NODE_ENV=<%= environment %>"
Expand Down
17 changes: 17 additions & 0 deletions extensions/systemd/systemd.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ class SystemdProcessManager extends cli.ProcessManager {
.catch((error) => Promise.reject(new cli.errors.ProcessError(error)));
}

success() {
try {
execa.shellSync(`systemd-notify --ready --pid=${process.pid} && sleep 10s`);
} catch (error) {
// Not much we can do other than throw unfortunately
throw new cli.errors.ProcessError(error);
}
}

error(error) {
try {
execa.shellSync(`systemd-notify --status='${error.message}' && sleep 10s`)
} catch (error) {
throw new cli.errors.ProcessError(error);
}
}

isEnabled() {
try {
execa.shellSync(`systemctl is-enabled ${this.systemdName}`);
Expand Down