Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I propose to replace the current server boot logic with a state-machine approach. At the same time, it is an opportunity to reconsider the various server-initialization issues, and streamline and standardize.
Motivation
Server boot logic has been a thorny problem for years. Even after multiple attempts to fix it, there remain edge cases, particularly with respect to remote server connection.
At least these, perhaps others.
There is also not a clear, central place to observe the boot/init process. The process is divided somewhat haphazardly between Server and ServerStatusWatcher methods and is not at all straightforward to trace.
Specification
Server
for user-facing control, andServerProcess
to manage a specific server process. A ServerProcess would be created when booting, or connecting to a remote server, and destroyed when that process exits. (Here, we might want a ServerRemoteProcess as well.)server.reboot
may be simplified by switching out ServerProcess objects.status_(newState)
where newState is a symbol descriptor. Each status change would perform initialization or shutdown tasks (below).A sketch of statuses and permitted state transitions:
Server.remote
could go directly to 'handshake'Upon a second read of this, I would add an 'unresponsive' state. If the aliveThread doesn't get a response,
status = \unresponsive
(and perhaps ignore these during init states). If the process shuts down (detected by unixCmd's action function), thenstatus = \idle
(and a transition into idle status is normal only from 'quitting' status -- otherwise the user would get a warning that the server crashed).Significant advantages would be 1/ we always know the current status, 2/ it's easy to evaluate whether the process flow is normal or abnormal, based on the previous state and the new state, and 3/ state changes would be centralized in one place.
I may have missed some details -- comments are more than welcome.
Drawbacks
I welcome discussion on this.
Unresolved Questions
Did I miss any statuses?
Did I overlook any subtleties of
Server.remote
?