From f34a855f320438fdb26cb6fd4762a173dfb02583 Mon Sep 17 00:00:00 2001 From: Kleissner Date: Mon, 15 Nov 2021 15:50:40 +0100 Subject: [PATCH] Document how to build the Windows GUI version (headless). Document API functions implemented in Cmd. --- API.go | 4 ++-- README.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/API.go b/API.go index a702c46..24c74fa 100644 --- a/API.go +++ b/API.go @@ -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) diff --git a/README.md b/README.md index c8411e7..d1353ce 100644 --- a/README.md +++ b/README.md @@ -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.