Ghost: Bringing One-Click/Automatic Updates to Ghost

Created on 15 Feb 2017  路  8Comments  路  Source: TryGhost/Ghost

It has been a feature long-requested by many users, and thanks to the new Ghost-CLI project, Automatic Updates are finally within reach!

Before this feature will work fully, however, there are several changes that need to be made across Ghost, Ghost-Admin, and Ghost-CLI, to provide the smoothest, most fault-tolerant update process. This issue exists to document and track those specific changes as they occur in the separate repositories.

Brief Overview

Currently, whenever there is a new Ghost version, a notification appears in Ghost-Admin prompting the user to update, and providing a link to the relevant support page with documentation as to how to manually update Ghost. This current notification would be extended and instead of linking to a support page, it would link to the /ghost/about page, where a button would appear that a user could click to update their blog.

Upon clicking the button, a server request would be made, and the Ghost server would communicate with the managing CLI process (ghost run), which would then trigger the ghost update command. As Ghost itself would still be running, the user could then continue using Ghost normally, and Ghost-Admin would poll the Ghost server in the background until 1 of 2 things happens:

  1. The update process erred, in which case Ghost-Admin would retrieve the error and display it (with perhaps a link to documentation).
  2. The update process succeeded, and the user needs to refresh the page to get the latest version of Ghost-Admin.

Additional Notes

  • The update process will only be available if Ghost is being run with Ghost-CLI.
  • The first iteration will only feature one-click updates through the admin client. Future versions will work on automatic updates that require no user interaction.

Tasks

Ghost-CLI

  • [ ] ghost update command should make sure blog can start before switching to new version (TryGhost/Ghost-CLI#153)

Basically, Ghost-CLI needs to be able to verify that the new version of Ghost has been installed correctly, and that there won't be any issues switching versions. With the current update process, the blog could be left in a broken state if the old version is stopped and the new one fails to start, so we want to make sure the new version will start correctly.

  • [ ] ghost update should communicate with the Ghost process (issue/PR # TBD)

Currently, Ghost-CLI starts ghost using a ghost run command, which allows the CLI to provide some light management of the core Ghost server process. Communication between the two process currently happens over IPC channels - and this should be extended to allow ghost update to tell ghost run that it has finished installing the new Ghost version, before it stops the old version, giving Ghost time to notify the client that the blog is restarting.

Ghost

  • [ ] Update API endpoint (PR in progress - #7977)

This endpoint handles communication with the Ghost-CLI process to start the update process, as well as inform Ghost-Admin of the update status.

There will be both a GET endpoint and a POST endpoint.

The GET endpoint will return a couple of things:

  1. New version if one is available
  2. Status flag signifying whether or not the blog is currently undergoing an update process.
  3. Any errors that occurred during update

The POST endpoint will:

  • Trigger the update process by sending an IPC message to Ghost-CLI

At the moment, only the blog owner will be able to update the blog, but it could be extended in the future to allow administrators as well, pending discussion.

As part of this endpoint, there will be a config variable added that controls whether or not the blog is able to be updated (for example, if you enable a particular privacy flag or if you're not running with Ghost-CLI).

Ghost-Admin

  • [ ] Make custom update notification that links to the About page.

Because the update button will be located on the About page, the update notification should link to the About page instead of a support page. This should also take into account the configuration of the server, so if the user is not running via Ghost-CLI, or has disabled CLI updates for any particular reason, then the notification will not link to the about page and instead show a different message.

  • [ ] Build polling service that will poll the server in the background at either fixed or increasing intervals to determine update status

The service should also check whenever Ghost-Admin is first loaded to see if Ghost is currently being updated, and trigger the polling process if it is. (Use case: user refreshes the page after starting an update process).

There should probably be a way to ask the service if Ghost is updating, and certain blog actions may need to be disabled during update (for example: theme uploads, import/export, etc.) - this may be added in future improvements

feature later server / core

Most helpful comment

Ghost-CLI currently is missing a couple of things needed to get this working, my thought was we'd be putting this off until after 1.0, as it's a fairly sizable feature that will require stuff in all three major Ghost components.

All 8 comments

@acburdine what's the status of this so far as Ghost-CLI is concerned?

Ghost-CLI currently is missing a couple of things needed to get this working, my thought was we'd be putting this off until after 1.0, as it's a fairly sizable feature that will require stuff in all three major Ghost components.

Ok, it was added to an internal sprint list so just wanted to check in on the current status so I can prioritise properly 馃槃

We had a conversation about this earlier today. Not sure what the status is, but the simple version that we were talking about was:

Running ghost autoupdate causes Ghost to setup a cron job that runs daily.
The cron job should do the following:

  • if there is a patch or minor update available, run ghost update
  • if there is a major update available, send an email

Not sure the best way to send an email, maybe an endpoint in Ghost?

The other thing to consider here, is that I _think_ we lost maintenance mode between LTS and 1.0.0? Original issue: https://github.com/TryGhost/Ghost/issues/6976

We should make sure that this is available, because ghost update could make use of it.

This might be a simple approach to getting this working?

That was actually something I had thought about as well. The email part might be a little tricky, but it's definitely a viable approach 馃憤

For what it's worth, I think https://github.com/TryGhost/Ghost-CLI/issues/153 is still a needed feature before even the simple approach can be considered - otherwise we would potentially run into the issue where ghost update would kill your blog because of some issue.

Any updates here?

Closing as feature, later until we decide to prioritise this

Was this page helpful?
0 / 5 - 0 ratings