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 issue with systemd "failed" state #761

Closed
acburdine opened this issue Jul 21, 2018 · 8 comments · Fixed by #769
Closed

Fix issue with systemd "failed" state #761

acburdine opened this issue Jul 21, 2018 · 8 comments · Fixed by #769

Comments

@acburdine
Copy link
Member

Summary

Right now, Ghost-CLI only has 2 options when it comes to determining the status of a Ghost instance: "running" and "not running". This has become problematic in the past, because systemd (which is used by default in production on Ubuntu) has the concept of a third state: "failed". This state occurs whenever the Ghost instance failed to start for a certain reason (e.g. a bad configuration file). Because of this, we currently throw an error when systemd is in state: "failed".

What I think we should do in the short term is fix the systemd process manager to output a more helpful error message (maybe auto-run journalctl to determine why it's in a failed state?) and maybe in the future refactor that particular part of the process manager to be able to handle that 3rd state more cleanly.

@kirrg001
Copy link
Contributor

kirrg001 commented Jul 26, 2018

Can't we just try to restart the blog with systemd if the status is failed? 🤔

I agree a clear error message would be helpful as well 👍

Other idea. Could we execute systemctl reset-failed to get rid of the failed state? Not sure where and when, but currently, the user is a little lost if that happens.

@kirrg001 kirrg001 self-assigned this Jul 26, 2018
@kirrg001
Copy link
Contributor

This is something we have to fix for CLI 1.9, i was running into this error today a couple of times while simulating a broken blog.

@kirrg001
Copy link
Contributor

kirrg001 commented Jul 27, 2018

.catch ((error) => {
  if (error.message.match(/failed/)) {
    return this.ui.sudo(`systemctl reset-failed ${this.systemdName}`)
      .then(() => {
        return Promise.resolve(false);
      });
   }
   .....
});

Something like this works nice. If your systemd process is in a "failed" state it means that Ghost has failed to start up and you have received the error already. You should be able to try again.

@acburdine
Copy link
Member Author

@kirrg001 that sounds like a perfect solution - I’ll work on testing that out this weekend

@kirrg001
Copy link
Contributor

@acburdine great 👍 :)

acburdine added a commit to acburdine/Ghost-CLI that referenced this issue Jul 28, 2018
closes TryGhost#761
- calls systemctl reset-failed when service is in failed state & returns false
- improve error handling by looking at the stdout rather than the error message
acburdine added a commit that referenced this issue Jul 29, 2018
closes #761
- calls systemctl reset-failed when service is in failed state & returns false
- improve error handling by looking at the stdout rather than the error message
@kirrg001
Copy link
Contributor

kirrg001 commented Aug 2, 2018

@acburdine There is another case.

If you run ghost ls if your systemd service is in the failed state.

@kirrg001
Copy link
Contributor

kirrg001 commented Aug 8, 2018

I'll reopen this issue, because there are more cases. Will try to look into this tomorrow.

@kirrg001 kirrg001 reopened this Aug 8, 2018
@github-actions
Copy link

github-actions bot commented May 3, 2021

Our bot has automatically marked this issue as stale because there has not been any activity here in some time. The issue will be closed soon if there are no further updates, however we ask that you do not post comments to keep the issue open if you are not actively working on a PR. We keep the issue list minimal so we can keep focus on the most pressing issues. Closed issues can always be reopened if a new contributor is found. Thank you for understanding 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants