github.com/alloyci/alloy-runner@v1.0.1-0.20180222164613-925503ccafd6/docs/commands/README.md (about) 1 # Alloy Runner Commands 2 3 Alloy Runner contains a set of commands with which you register, manage and 4 run your builds. 5 6 You can check a recent list of commands by executing: 7 8 ```bash 9 alloy-runner --help 10 ``` 11 12 Append `--help` after a command to see its specific help page: 13 14 ```bash 15 alloy-runner <command> --help 16 ``` 17 18 ## Using environment variables 19 20 Most of the commands support environment variables as a method to pass the 21 configuration to the command. 22 23 You can see the name of the environment variable when invoking `--help` for a 24 specific command. For example, you can see below the help message for the `run` 25 command: 26 27 ```bash 28 alloy-runner run --help 29 ``` 30 31 The output would be similar to: 32 33 ```bash 34 NAME: 35 alloy-runner run - run multi runner service 36 37 USAGE: 38 alloy-runner run [command options] [arguments...] 39 40 OPTIONS: 41 -c, --config "/Users/username/.alloy-runner/config.toml" Config file [$CONFIG_FILE] 42 ``` 43 44 ## Running in debug mode 45 46 Debug mode is especially useful when looking for the cause of some undefined 47 behavior or error. 48 49 To run a command in debug mode, prepend the command with `--debug`: 50 51 ```bash 52 alloy-runner --debug <command> 53 ``` 54 55 ## Super-user permission 56 57 Commands that access the configuration of AlloyCI Runner behave differently when 58 executed as super-user (`root`). The file location depends on the user executing 59 the command. 60 61 Be aware of the notice that is written when executing the commands that are 62 used for running builds, registering services or managing registered runners: 63 64 ```bash 65 alloy-runner run 66 67 INFO[0000] Starting multi-runner from /Users/username/.alloy-runner/config.toml ... builds=0 68 WARN[0000] Running in user-mode. 69 WARN[0000] Use sudo for system-mode: 70 WARN[0000] $ sudo alloy-runner... 71 ``` 72 73 You should use `user-mode` if you are really sure that this is a mode that you 74 want to work with. Otherwise, prefix your command with `sudo`: 75 76 ``` 77 sudo alloy-runner run 78 79 INFO[0000] Starting multi-runner from /etc/alloy-runner/config.toml ... builds=0 80 INFO[0000] Running in system-mode. 81 ``` 82 83 In the case of **Windows** you may need to run the **Command Prompt** in 84 **Administrative Mode**. 85 86 ## Configuration file 87 88 Alloy Runner configuration uses the [TOML] format. 89 90 The file to be edited can be found in: 91 92 1. `/etc/alloy-runner/config.toml` on \*nix systems when alloy-runner is 93 executed as super-user (`root`) 94 1. `~/.alloy-runner/config.toml` on \*nix systems when alloy-runner is 95 executed as non-root 96 1. `./config.toml` on other systems 97 98 Most of the commands accept an argument to specify a custom configuration file, 99 allowing you to have a multiple different configurations on a single machine. 100 To specify a custom configuration file use the `-c` or `--config` flag, or use 101 the `CONFIG_FILE` environment variable. 102 103 [TOML]: https://github.com/toml-lang/toml 104 105 ## Signals 106 107 It is possible to use system signals to interact with AlloyCI Runner. The 108 following commands support the following signals: 109 110 | Command | Signal | Action | 111 |---------|--------|--------| 112 | `register` | **SIGINT** | Cancel runner registration and delete if it was already registered | 113 | `run`, `exec`, `run-single` | **SIGINT**, **SIGTERM** | Abort all running builds and exit as soon as possible. Use twice to exit now (**forceful shutdown**). | 114 | `run`, `exec`, `run-single` | **SIGQUIT** | Stop accepting a new builds. Exit as soon as currently running builds do finish (**graceful shutdown**). | 115 | `run` | **SIGHUP** | Force to reload configuration file | 116 117 If your operating system is configured to automatically restart the service if it fails (which is the default on some platforms) it may automatically restart the runner if it's shut down by the signals above. 118 119 ## Commands overview 120 121 This is what you see if you run `alloy-runner` without any arguments: 122 123 ```bash 124 NAME: 125 alloy-runner - a AlloyCI Runner 126 127 USAGE: 128 alloy-runner [global options] command [command options] [arguments...] 129 130 VERSION: 131 1.0.0~beta.142.ga8d37f3 (a8d37f3) 132 133 AUTHOR(S): 134 Patricio Cano <support@alloy-ci.com> 135 136 COMMANDS: 137 exec execute a build locally 138 run run multi runner service 139 register register a new runner 140 install install service 141 uninstall uninstall service 142 start start service 143 stop stop service 144 restart restart service 145 status get status of a service 146 run-single start single runner 147 unregister unregister specific runner 148 verify verify all registered runners 149 archive find and archive files (internal) 150 artifacts upload build artifacts (internal) 151 extract extract files from an archive (internal) 152 help, h Shows a list of commands or help for one command 153 ``` 154 155 Below we will explain what each command does in detail. 156 157 ## Registration-related commands 158 159 The following commands allow you to register a new runner, or list and verify 160 them if they are still registered. 161 162 - [alloy-runner register](#alloy-runner-register) 163 - [Interactive registration](#interactive-registration) 164 - [Non-interactive registration](#non-interactive-registration) 165 - [alloy-runner list](#alloy-runner-list) 166 - [alloy-runner verify](#alloy-runner-verify) 167 - [alloy-runner unregister](#alloy-runner-unregister) 168 169 The above commands support the following arguments: 170 171 | Parameter | Default | Description | 172 |-------------|---------|-------------| 173 | `--config` | See the [configuration file section](#configuration-file) | Specify a custom configuration file to be used | 174 175 ### alloy-runner register 176 177 This command registers your Alloy Runner in AlloyCI. The registered runner is 178 added to the [configuration file](#configuration-file). 179 You can use multiple configurations in a single AlloyCI Runner. Executing 180 `alloy-runner register` adds a new configuration entry, it doesn't remove the 181 previous ones. 182 183 There are two options to register a Runner, interactive and non-interactive. 184 185 #### Interactive registration 186 187 This command is usually used in interactive mode (**default**). You will be 188 asked multiple questions during a Runner's registration. 189 190 This question can be pre-filled by adding arguments when invoking the registration command: 191 192 alloy-runner register --name my-runner --url http://alloyci.example.com --registration-token my-registration-token 193 194 Or by configuring the environment variable before the `register` command: 195 196 export CI_SERVER_URL=http://alloyci.example.com 197 export RUNNER_NAME=my-runner 198 export REGISTRATION_TOKEN=my-registration-token 199 export REGISTER_NON_INTERACTIVE=true 200 alloy-runner register 201 202 To check all possible arguments and environments execute: 203 204 alloy-runner register --help 205 206 #### Non-interactive registration 207 208 It's possible to use registration in non-interactive / unattended mode. 209 210 You can specify the arguments when invoking the registration command: 211 212 alloy-runner register --non-interactive <other-arguments> 213 214 Or by configuring the environment variable before the `register` command: 215 216 <other-environment-variables> 217 export REGISTER_NON_INTERACTIVE=true 218 alloy-runner register 219 220 > **Note:** Boolean parameters must be passed in the command line with `--key={true|false}`. 221 222 ### alloy-runner list 223 224 This command lists all runners saved in the 225 [configuration file](#configuration-file). 226 227 ### alloy-runner verify 228 229 This command checks if the registered runners can connect to AlloyCI, but it 230 doesn't verify if the runners are being used by the AlloyCI Runner service. An 231 example output is: 232 233 ```bash 234 Verifying runner... is alive runner=fee9938e 235 Verifying runner... is alive runner=0db52b31 236 Verifying runner... is alive runner=826f687f 237 Verifying runner... is alive runner=32773c0f 238 ``` 239 240 To delete the old and removed from AlloyCI runners, execute the following 241 command. 242 243 >**Warning:** 244 This operation cannot be undone, it will update the configuration file, so 245 make sure to have a backup of `config.toml` before executing it. 246 247 ```bash 248 alloy-runner verify --delete 249 ``` 250 251 ### alloy-runner unregister 252 253 This command allows to unregister one of the registered runners. It expects 254 either a full URL and the runner's token, or the runner's name. With the 255 `--all-runners` option it will unregister all the attached runners. 256 257 To unregister a specific runner, first get the runner's details by executing 258 `alloy-runner list`: 259 260 ```bash 261 test-runner Executor=shell Token=t0k3n URL=http://alloyci.example.com 262 ``` 263 264 Then use this information to unregister it, using one of the following commands. 265 266 >**Warning:** 267 This operation cannot be undone, it will update the configuration file, so 268 make sure to have a backup of `config.toml` before executing it. 269 270 #### By URL and token: 271 272 ```bash 273 alloy-runner unregister --url http://alloyci.example.com/ --token t0k3n 274 ``` 275 276 #### By name: 277 278 > **Note:** If there is more than one runner with the given name, only the first one will be removed 279 280 ```bash 281 alloy-runner unregister --name test-runner 282 ``` 283 284 #### All Runners: 285 286 ```bash 287 alloy-runner unregister --all-runners 288 ``` 289 290 ## Service-related commands 291 292 > **Note:** Starting with AlloyCI Runner 1.0.0, service-related commands are **deprecated** 293 and will be removed in one of the upcoming releases. 294 295 The following commands allow you to manage the runner as a system or user 296 service. Use them to install, uninstall, start and stop the runner service. 297 298 - [alloy-runner install](#alloy-runner-install) 299 - [alloy-runner uninstall](#alloy-runner-uninstall) 300 - [alloy-runner start](#alloy-runner-start) 301 - [alloy-runner stop](#alloy-runner-stop) 302 - [alloy-runner restart](#alloy-runner-restart) 303 - [alloy-runner status](#alloy-runner-status) 304 - [Multiple services](#multiple-services) 305 - [**Access Denied** when running the service-related commands](#access-denied-when-running-the-service-related-commands) 306 307 All service related commands accept these arguments: 308 309 | Parameter | Default | Description | 310 |-----------|---------|-------------| 311 | `--service` | `alloy-runner` | Specify custom service name | 312 | `--config` | See the [configuration file](#configuration-file) | Specify a custom configuration file to use | 313 314 ### alloy-runner install 315 316 This command installs AlloyCI Runner as a service. It accepts different sets of 317 arguments depending on which system it's run on. 318 319 When run on **Windows** or as super-user, it accepts the `--user` flag which 320 allows you to drop privileges of builds run with the **shell** executor. 321 322 | Parameter | Default | Description | 323 |-----------|---------|-------------| 324 | `--service` | `alloy-runner` | Specify a custom name for the Runner | 325 | `--working-directory` | the current directory | Specify the root directory where all data will be stored when builds will be run with the **shell** executor | 326 | `--user` | `root` | Specify the user which will be used to execute builds | 327 | `--password` | none | Specify the password for the user that will be used to execute the builds | 328 329 ### alloy-runner uninstall 330 331 This command stops and uninstalls the AlloyCI Runner from being run as an 332 service. 333 334 ### alloy-runner start 335 336 This command starts the AlloyCI Runner service. 337 338 ### alloy-runner stop 339 340 This command stops the AlloyCI Runner service. 341 342 ### alloy-runner restart 343 344 This command stops and then starts the AlloyCI Runner service. 345 346 ### alloy-runner status 347 348 This command prints the status of the AlloyCI Runner service. The exit code is zero when the service is running and non-zero when the service is not running. 349 350 ### Multiple services 351 352 By specifying the `--service` flag, it is possible to have multiple AlloyCI 353 Runner services installed, with multiple separate configurations. 354 355 ## Run-related commands 356 357 This command allows to fetch and process builds from AlloyCI. 358 359 ### alloy-runner run 360 361 This is main command that is executed when AlloyCI Runner is started as a 362 service. It reads all defined Runners from `config.toml` and tries to run all 363 of them. 364 365 The command is executed and works until it [receives a signal](#signals). 366 367 It accepts the following parameters. 368 369 | Parameter | Default | Description | 370 |-----------|---------|-------------| 371 | `--config` | See [#configuration-file](#configuration-file) | Specify a custom configuration file to be used | 372 | `--working-directory` | the current directory | Specify the root directory where all data will be stored when builds will be run with the **shell** executor | 373 | `--user` | the current user | Specify the user that will be used to execute builds | 374 | `--syslog` | `false` | Send all logs to SysLog (Unix) or EventLog (Windows) | 375 | `--metrics-server` | empty | Address (`<host>:<port>`) on which the Prometheus metrics HTTP server should be listening | 376 377 ### alloy-runner run-single 378 379 This is a supplementary command that can be used to run only a single build 380 from a single AlloyCI instance. It doesn't use any configuration file and 381 requires to pass all options either as parameters or environment variables. 382 The AlloyCI URL and Runner token need to be specified too. 383 384 For example: 385 386 ```bash 387 alloy-runner run-single -u http://alloyci.example.com -t my-runner-token --executor docker --docker-image ruby:2.1 388 ``` 389 390 You can see all possible configuration options by using the `--help` flag: 391 392 ```bash 393 alloy-runner run-single --help 394 ``` 395 396 You can use the `--max-builds` option to control how many builds the runner will execute before exiting. The 397 default of `0` means that the runner has no build limit and will run jobs forever. 398 399 You can also use the `--wait-timeout` option to control how long the runner will wait for a job before 400 exiting. The default of `0` means that the runner has no timeout and will wait forever between jobs. 401 402 ## Internal commands 403 404 AlloyCI Runner is distributed as a single binary and contains a few internal 405 commands that are used during builds. 406 407 ### alloy-runner artifacts-downloader 408 409 Download the artifacts archive from AlloyCI. 410 411 ### alloy-runner artifacts-uploader 412 413 Upload the artifacts archive to AlloyCI. 414 415 ### alloy-runner cache-archiver 416 417 Create a cache archive, store it locally or upload it to an external server. 418 419 ### alloy-runner cache-extractor 420 421 Restore the cache archive from a locally or externally stored file. 422 423 ## Troubleshooting 424 425 Below are some common pitfalls. 426 427 ### **Access Denied** when running the service-related commands 428 429 Usually the [service related commands](#service-related-commands) require 430 administrator privileges: 431 432 - On Unix (Linux, OSX, FreeBSD) systems, prefix `alloy-runner` with `sudo` 433 - On Windows systems use the elevated command prompt. 434 Run an `Administrator` command prompt ([How to][prompt]). 435 The simplest way is to write `Command Prompt` in the Windows search field, 436 right click and select `Run as administrator`. You will be asked to confirm 437 that you want to execute the elevated command prompt.