Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
100 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,8 @@ package main | |
|
||
import ( | ||
"github.com/burke/zeus/zeus" | ||
"fmt" | ||
) | ||
|
||
func main () { | ||
fmt.Println(zeus.Run()) | ||
zeus.Run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Master/Slave Handshake | ||
|
||
#### 1. Socket | ||
|
||
The Slave is always started with an environment variable named `ZEUS_MASTER_FD`. The file descriptor at the given integer value is a socket to the Master process. | ||
|
||
The Slave should open a UNIX Domain Socket using the `ZEUS_MASTER_FD` File Descriptor (`globalMasterSock`). | ||
|
||
The Slave opens a new UNIX datagram Socketpair (`local`, `remote`) | ||
|
||
The Slave sends `remote` across `globalMasterSock`. | ||
|
||
#### 2. PID and Identifier | ||
|
||
The Slave determines whether it has been given an Identifier. If it is the first-booted slave, it was booted | ||
by the Master, and will not have one. When a Slave forks, it is passed an Identifier by the Master that it | ||
passes along to the newly-forked process. | ||
|
||
The Slave sends a JSON-encoded hash of "pid" and "identifier", with "pid" being the integer pid of the current process, | ||
and "identifier" being the identifier, if there is one, or the empty string if none. | ||
|
||
#### 3. Action | ||
|
||
The Master now sends, along `remote`, a string containing the code representing the action for this Slave. | ||
|
||
The Slave evaluates this code. | ||
|
||
#### 4. Action Result | ||
|
||
If there were no runtime errors in evaluating the action, the Slave writes "OK" to `local`. | ||
|
||
If there were runtime errors, the slave returns a string representing the errors in an arbitrary and | ||
hopefully helpful format. It should normally be identical to the console output format should the errors | ||
have been raised and printed to stderr. | ||
|
||
#### 5. Loaded Files | ||
|
||
Any time after the action has been executed, the Slave may (and should) send, over `local`, a list of files | ||
that have been newly-loaded in the course of evaluating the action. | ||
|
||
Languages are expected to implement this using clever tricks. | ||
|
||
Steps 1-4 happend sequentially and in-order, but Submitting files in Step 5 should not prevent the Slave from | ||
handling further commands from the master. The Slave should be considered 'connected' after Step 4. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Terminology | ||
|
||
* a Client is a process initiated by the user requesting zeus to run a command. | ||
|
||
* the Master is the Go program which mediates all the interaction between the other processes | ||
|
||
* a Slave is a process managed by Zeus which is used to load dependencies for commands | ||
|
||
* a Command process is one forked from a Slave and connected to a Client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters