Closed joeinnes closed 4 years ago
I think I'm registering the callback on line 112, which eventually calls the afterInit
callback on line 117.
The grace period of 0 I think just starts closing sockets immediately.
I believe it would work like this:
monitor
starts, creates an http server, but doesn't listen anywheremonitor
starts Apostrophemonitor
starts the http server listening on the appropriate portmonitor
to try to start Apostrophe againafterInit
functionmonitor
instructs the http server to close all connections immediately.stop()
method fires - at this point, the port should be free to useafterInit()
function What would be the benefit of reusing the listening socket compared to Apostrophe just serving a stack trace on error, regardless of monitor
?
Missed that. Seems kosher to me.
Apostrophe can't catch all errors. There's no such thing as async try/catch in old school callback driven code. One of the reasons why A3 is async/await everywhere and uses the apiRoutes feature heavily.
On Thu, Apr 23, 2020 at 4:45 PM Joe Innes notifications@github.com wrote:
I think I'm registering the callback on line 112 https://github.com/joeinnes/apostrophe-monitor/blob/13a60eda079f715d494d6ed632f61bbf9de2f957/monitor.js#L112, which eventually calls the afterInit callback on line 117 https://github.com/joeinnes/apostrophe-monitor/blob/13a60eda079f715d494d6ed632f61bbf9de2f957/monitor.js#L117 .
The grace period of 0 I think just starts closing sockets immediately.
I believe it would work like this:
- monitor starts, creates an http server, but doesn't listen anywhere
- monitor starts Apostrophe
- Error causes Apostrophe to exit
- monitor starts the http server listening on the appropriate port
- User fixes the error which caused Apostrophe to exit
- Apostrophe triggers the afterInit function
- monitor instructs the http server to close all connections immediately
- Once all connections close, the callback from the .stop() method fires - at this point, the port should be free to use
- This fires the callback provided to the afterInit() function
- Apostrophe gets on with its usual business.
What would be the benefit of reusing the listening socket compared to Apostrophe just serving a stack trace on error, regardless of monitor?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/apostrophecms/apostrophe-monitor/pull/7#issuecomment-618659038, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAH27LTIBKTIQEHIMGSBMTROCSF5ANCNFSM4MPF3RMQ .
--
THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER APOSTROPHECMS | apostrophecms.com | he/him/his
Yes, I saw that. I am not sure how to set the initFailed function from inside monitor
though - it seems that it requires app.js, which in turn requires apostrophe with the options object.
I can't see a way to get a callback defined in monitor
onto the Apostrophe's initFailed option until after it's too late and Apostrophe has already loaded (and/or crashed).
Yeah, good point, we can't do that without changing the pattern by which one uses apostrophe-monitor. Good enough for now (and then some)!
On Fri, Apr 24, 2020 at 1:12 PM Joe Innes notifications@github.com wrote:
Yes, I saw that. I am not sure how to set the initFailed function from inside monitor though - it seems that it requires app.js, which in turn requires apostrophe with the options object.
I can't see a way to get a callback defined in monitor onto the Apostrophe's initFailed option until after it's too late and Apostrophe has already loaded (and/or crashed).
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/apostrophecms/apostrophe-monitor/pull/7#issuecomment-619138505, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAH27PV6CYCWH3KDGAPCODROHB63ANCNFSM4MPF3RMQ .
--
THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER APOSTROPHECMS | apostrophecms.com | he/him/his
Thanks! This will be in the next release.
On Fri, Apr 24, 2020 at 1:51 PM Tom Boutell tom@apostrophecms.com wrote:
Yeah, good point, we can't do that without changing the pattern by which one uses apostrophe-monitor. Good enough for now (and then some)!
On Fri, Apr 24, 2020 at 1:12 PM Joe Innes notifications@github.com wrote:
Yes, I saw that. I am not sure how to set the initFailed function from inside monitor though - it seems that it requires app.js, which in turn requires apostrophe with the options object.
I can't see a way to get a callback defined in monitor onto the Apostrophe's initFailed option until after it's too late and Apostrophe has already loaded (and/or crashed).
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/apostrophecms/apostrophe-monitor/pull/7#issuecomment-619138505, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAH27PV6CYCWH3KDGAPCODROHB63ANCNFSM4MPF3RMQ .
--
THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER APOSTROPHECMS | apostrophecms.com | he/him/his
--
THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER APOSTROPHECMS | apostrophecms.com | he/him/his
Current behaviour: if Apostrophe can't start (eg: syntax error in a module's index.js), monitor exits to the terminal.
This PR allows monitor to continue running in case Apostrophe doesn't start, and instead runs a basic HTTP server which will return the error message and stack dump, until the error is fixed and Apostrophe can run successfully again.