Conversation
|
Thanks @jamshark70 |
|
Just to contribute a thought to this. The current implementation doesn't make a clear difference between the language as a process that creates another process and the language as a client that connects to a, possibly remote, server. I gave it some thoughts in the past and that was a key problem because process instantiation errors can't be caught and described and they might mix with connection issues. For this the server process could return different errnos (this was discussed in the past, I don’t remember where) to be handled. |
A ServerProcess object could help with this by subclassing: ServerProcess, ServerInternalProcess, ServerRemoteProcess. |
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
Serverfor user-facing control, andServerProcessto 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.rebootmay 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.remotecould 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?