website/content/articles/config.md

4.4 KiB

title date description version weight
Configuration File Reference 2020-07-29T20:42:50-04:00 Conductor config file reference 0.3.2 1

Configuration file

Conductor will look in the current directory or any parent directory for configuration file named conductor.yaml. In general you can place this configuration directory in or above any place you might want to run the stack.

Manually specifying the configuration file

If the configuration file is located outside the current directory structure you can specify it with the -c flag.

conductor -c /path/to/config/conductor.yaml

Project configuration

The top level of the configuration has various configurational options for the entire stack.

name: MyProject
services:
- name: mysql
- name: rabbit
groups:
- name: group1
  components: 
  - component1
  - component2
- name: group2
  components: 
  - component1
  - component3
components:
  # ...
  • name - An arbitrary name for the project
  • services - An array of external services that can be launched by components. Currently only docker containers are supported.
    • name - The name of the docker container to launch
  • groups - An array of groups can be defined to execute multiple components together
    • name - An arbitrary name for the group
    • components - An array of component names that should be launched as a group

Component configuration

Components are indvidual applications that are run as part of the stack. All, some, or one of the compoennts can be launched.

Example component configuration:

- name: api
  color: Red
  path: backend/api-gateway
  tags: 
  - api
  - web
  env:
    COLORS: 1
    NPM_ENV: debug
  start:
    command: npm
    args:
    - start
  init:
    - command: npm
      args:
      - install
  repo:
    https://github.com/me/my-project.git
  • name - The name for the component. This name is used in the log output and can also be specified as a sub-command to run the component itself.
  • path - The working path relative to the configuration file. If not specified the path is assuemd to be a subfolder with the component name.
  • env - A set of environment variables that are set before any commands are run.
  • color - The component will use this color in the log output. Valid color values are: Yellow, Blue, Green, Red, and Purple.
  • tags - A list of tags to identify the component. These can be used to execute groups of components using the --tags flag.
  • start - A command block that is executed when the component is ran
  • init - A list of command blocks that are ran when the component is initialized
  • repo - The repository url for the component. When running init all components are cloned into subfolders if they have repositories specified and their init commands are ran.
  • retry - Specifies whether the command should be rerun if it exits. This is true by default. Setting this to false will cause the command to be executed. This does not apply to init commands.
  • delay - A delay in seconds to wait before executing this command. This is useful if it needs to wait for another component to spin up.
  • default - If set to false the component will not be ran when the bare conductor or conductor run is executed.

Command block reference

  • command - the name of the command to run
  • args - A list of arguments to pass to the command
  • env - A list of environment variables to set specific to this command
  • dir - An optional working directory override if the command should be ran somewhere other than the component path

Full example config:

name: My Web Application
services:
- name: mysql
groups:
- name: full
  components:
  - frontend
  - backend
 
components:
- name: frontend
  env:
    FORCE_COLOR: 1
  color: Blue
  tags: 
  - core
  start:
   command: npm
   args:
   - start
  init: 
  - command: npm
    args:
    - install
- name: backend
  services:
  - mysql
  color: Purple
  tags:
  - core
  start:
  - command: mix
    args:
    -  phx.server
  init:
  - command: mix
    args:
    - deps.get
  - command: mix
    args:
    - compile
- name: production-backend
  default: false
  env:
    MIX_ENV: production
  color: Purple
  tags:
  - core
  start:
  - command: mix
    args:
    -  phx.server
  init:
  - command: mix
    args:
    - deps.get
  - command: mix
    args:
    - compile