Rework README
[src/xds/xds-agent.git] / README.md
1 # XDS - X(cross) Development System Agent
2
3 XDS-agent is an agent that should run on your local host when you use XDS.
4
5 This agent takes care, among others, of starting [Syncthing](https://syncthing.net/)
6 tool to synchronize your project files from your local host to XDS build server
7 machine or container (where `xds-server` is running).
8
9 > **SEE ALSO**: [xds-server](https://github.com/iotbzh/xds-server), a web server
10 used to remotely cross build applications.
11
12 ## How to run
13
14 First you need to download `xds-agent` tarballs from xds dashboard by clicking
15 on download icon ![download icon](./resources/images/download_icon.jpg) of
16 configuration page.
17
18 > **NOTE** : you can also download released tarballs from github [releases page](https://github.com/iotbzh/xds-agent/releases).
19
20 Then unzip this tarball any where into your local disk.
21
22 ## Configuration
23
24 xds-agent configuration is driven by a JSON config file (named `agent-config.json`).
25 The tarball mentioned in previous section includes this file with default settings.
26
27 Here is the logic to determine which `agent-config.json` file will be used:
28 1. from command line option: `--config myConfig.json`
29 2. `$HOME/.xds/agent-config.json` file
30 3. `<current dir>/agent-config.json` file
31 4. `<xds-agent executable dir>/agent-config.json` file
32
33 Supported fields in configuration file are (all fields are optional and listed
34 values are the default values):
35 ```
36 {
37     "httpPort": "8010",                             # http port of agent REST interface
38     "logsDir": "/tmp/logs",                         # directory to store logs (eg. syncthing output)
39     "syncthing": {
40         "binDir": ".",                              # syncthing binaries directory (default: executable directory)
41         "home": "${HOME}/.xds/syncthing-config",    # syncthing home directory (usually .../syncthing-config)
42         "gui-address": "http://localhost:8384",     # syncthing gui url (default http://localhost:8384)
43         "gui-apikey": "123456789",                  # syncthing api-key to use (default auto-generated)
44     }
45 }
46 ```
47
48 >**NOTE:** environment variables are supported by using `${MY_VAR}` syntax.
49
50 ## Start-up
51
52 Simply to start `xds-agent` executable
53 ```bash
54 ./xds-agent &
55 ```
56
57 >**NOTE** if need be, you can increase log level by setting option
58 `--log <level>`, supported *level* are: panic, fatal, error, warn, info, debug.
59
60 You can now use XDS dashboard and check that connection with `xds-agent` is up.
61 (see also [xds-server README](https://github.com/iotbzh/xds-server/blob/master/README.md#xds-dashboard))
62
63
64 ## Build xds-agent from scratch
65
66 ### Dependencies
67
68 - Install and setup [Go](https://golang.org/doc/install) version 1.8 or
69 higher to compile this tool.
70
71 ### Building
72
73 Clone this repo into your `$GOPATH/src/github.com/iotbzh` and use delivered Makefile:
74 ```bash
75  mkdir -p $GOPATH/src/github.com/iotbzh
76  cd $GOPATH/src/github.com/iotbzh
77  git clone https://github.com/iotbzh/xds-agent.git
78  cd xds-agent
79  make all
80 ```
81
82 And to install xds-agent (by default in `/usr/local/bin`):
83 ```bash
84 make install
85 ```
86
87 >**NOTE:** Used `DESTDIR` to specify another install directory
88 >```bash
89 >make install DESTDIR=$HOME/opt/xds-agent
90 >```
91
92 #### Cross build
93 For example on a Linux machine to cross-build for Windows, just execute:
94 ```bash
95 export GOOS=windows
96 export GOARCH=amd64
97 make all
98 make package
99 ```