go build ./cmd/server
go build ./cmd/client
Note that the client is for testing purposes.
You need to set the SERVER_AUTH_TOKEN
environment variable. Share this securely with your client(s). The client will need to pass along this same token via the X-Session-Token
HTTP header. If it doesn't or the tokens don't match, then the client will receive a "403 Forbidden" error.
You also need to pass in the certificate and the certificate key.
Some example invocations:
./server -h
To cause the server to actually start, do something like:
SERVER_AUTH_TOKEN=micah1 ./server -certpath mytest.pem -keypath mytest-key.pem
Returns the current version number
Causes the server to quit
Runs a program to completion. Requires the following argument:
// jsonCommandStruct represents a command to be executed.
type jsonCommandStruct struct {
TimeoutInSecs float32 `json:"timeout"` // anything positive will be considered a timeout
Cmd string `json:"cmd"`
Args []string `json:"args"`
}
Runs a program in the background. Requires the following argument (same as above):
// jsonCommandStruct represents a command to be executed.
type jsonCommandStruct struct {
TimeoutInSecs float32 `json:"timeout"` // anything >0 will be considered a timeout
Cmd string `json:"cmd"`
Args []string `json:"args"`
}
Lists the running jobs
Terminates a job. Requires the following argument:
// jsonKillStruct represents a job to be killed.
// note that if job == -1, then all jobs will be killed
type jsonKillStruct struct {
JobNo JobNoType `json:"job"`
}
curl --header "Content-Type: application/json" \
-H "X-Session-Token: micah1" \
--request POST \
--data '{"timeout":0,"cmd":"sleep","args":["5"]}' \
https://localhost:8888/runInBackground