Add promise to ghost startup process to allow#2225
Conversation
core/index.js
Outdated
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
|
I moved the usage of I also rejected the promise there for consistency's sake even though it never gets hit due to the process quitting. |
|
Sooo I finally got around to testing this :) I'm excited about this change and what it could do for our tests. However, I believe there is still a little bit of refactoring work needed in server/index.js: The function I'm wondering if we can wrap I also noticed that throwing a random error during the chain did not result in Whilst I'm here looking at this file, I also think it could do with some serious love - it's a higgledy-piggledy collection of stuff at the moment. I wonder if we can make the promise chain clearer somehow? I'm adding this here because @hswolff you have been the king of the general app structure refactoring and may have ideas, but it's obviously not actually part of this PR - more like part of #2182. |
|
Updated the PR to fix the issue where Where did you throw errors that resulted in improper handling? I can approach some clean-up as a follow-on to this PR for sure. I can apply it in pursuit of #2182. |
|
I just threw an error in the last async block here: https://github.com/hswolff/Ghost/blob/d7ac4d44325641b11b7ab480f1307c3cbafeef2a/core/server/index.js#L213 |
|
Aha...so reason for that is https://github.com/hswolff/Ghost/blob/ghost-startup/core/index.js#L24 - we have our own specific error handling. Either we can pull our specific handling to end the process or just expose the error to the user to handle with as they please. |
|
It seems to me that if I get a success through the promise I should be able to get the failure that way too? It's not doing anything terrible right now just not consistent. What do you think? |
|
I think it'd be best to keep consistent and allowed to be managed by user land. |
|
Keep getting this random errors that occur occasionally. It's not consistent though. |
|
@hswolff the build error is a timing problem where |
|
Ok so this is now working perfectly in the module context, but in normal Ghost context, it just hangs. (I am adding Can we reconcile the two so that both work as expected i.e. there is an error message? Update I think all that is needed is to call logErrorAndExit in the main ghost index file? |
hooking into when ghost has finished loading addresses item 9 in TryGhost#2078 and makes progress on TryGhost#2182 - has files that startup ghost return a promise that is resolved once ghost has finished loading - moves getSocket into config file - removes models.reset() as it's not used anywhere - update functions in server startup - remove unused version hash variable
Add promise to ghost startup process to allow
hooking into when ghost has finished loading
addresses item 9 in #2078
that is resolved once ghost has finished loading
For example, this can be used like so: