Document how to build the Windows GUI version (headless). Document API functions implemented in Cmd.

This commit is contained in:
Kleissner
2021-11-15 15:50:40 +01:00
parent 6e27e7c003
commit f34a855f32
2 changed files with 58 additions and 2 deletions

4
API.go
View File

@@ -60,10 +60,10 @@ func parseDuration(input string) (result time.Duration) {
}
/*
apiConsole provides a websocket to send/receive internal commands
apiConsole provides a websocket to send/receive internal commands.
Request: GET /console
Result: 200 with JSON structure apiResponsePeerSelf
Result: Upgrade to websocket. The websocket message are texts to read/write.
*/
func apiConsole(w http.ResponseWriter, r *http.Request) {
c, err := webapi.WSUpgrader.Upgrade(w, r, nil)

View File

@@ -18,6 +18,15 @@ To reduce the binary size provide the linker switch -s which will "Omit the symb
go build -ldflags "-s"
```
### Windows Headless Version
To build a headless version (like a typical Windows GUI application) that does not show the command line window use the following linker switch. The second example reduces the file size.
```
go build -ldflags "-H=windowsgui"
go build -ldflags "-H=windowsgui -s"
```
## Use
The config filename is hard-coded to `Config.yaml` and is created on the first run. Please see the core library for individual settings to change.
@@ -77,6 +86,53 @@ APITimeoutRead: "10m" # The maximum duration for reading the e
APITimeoutWrite: "10m" # The maximum duration before timing out writes of the response. This includes processing time and is therefore the max time any HTTP function may take.
```
## API Functions
All API functions provided by the core library are described [here](https://github.com/PeernetOfficial/core/tree/master/webapi).
In addition, this application also provides these functions:
```
/console Websocket to send/receive internal commands
/shutdown Graceful shutdown
```
### Console
This provides a websocket to send/receive internal commands in the same way provided via the command line interface. The websocket messages sent to the API are the input texts from the end-user, and the messages received from the API are the text outputs.
This can be useful as internal debug interface in clients.
```
Request: GET /console
Result: Upgrade to websocket. The websocket message are texts to read/write.
```
### Shutdown
This gracefully shuts down the application. Actions: 0 = Shutdown.
```
Request: GET /shutdown?action=[action]
Result: 200 with JSON structure apiShutdownStatus
```
```go
type apiShutdownStatus struct {
Status int `json:"status"` // Status of the API call. 0 = Success.
}
```
Example request: `http://127.0.0.1:112/shutdown?action=0`
Example response:
```json
{
"status": 0
}
```
## Error Handling
The application exits in case of the errors listed below and uses the specified exit code. Applications that launch this application can monitor for those exit codes. End users should look into the log file for additional information in case any of these errors occur, although some of them are pre log file initialization.