Skip to content

A lightweight services composer written in Golang for managing services (processes) in a development environment.

License

Notifications You must be signed in to change notification settings

hadialqattan/go-compose

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Compose

go-compose carbon image

A lightweight services composer written in Golang for managing services (processes) in a development environment.


Installation

$ go get github.com/hadialqattan/go-compose

Usage

$ go-compose start # --config path/to/go-compose.yaml [default=./go-compose.yaml].

go-compose.yaml

services:
  service_name:
    ignore_failures: false
    sub_service: false
    auto_restart: true
    hooks:
        wait: 
            - another_service_name
        stop:
            - another_service_name
        start:
            - another_service_name
    cwd: .
    command: echo "shell script"
    environs:
      ENVIRONMENT_VARIABLE: true
  • services: a set of services to run.
  • ignore_failures: don't stop other services when this failed.
  • sub_service: don't start this service. this may be started by another service using the start hook.
  • auto_restart: automatically restart this service if it crashed.
  • hooks:
    • wait: wait for other services to stop before starting (setup).
    • stop: stop other services on exit (teardown).
    • start: start other services/sub-services on exit (teardown).
  • cwd: where the command will be executed (Command Work Directory).
  • command: a unix shell command.
  • environs: environment variables.
A real world example
services:

  webapp:
    ignore_failures: true
    auto_restart: true
    hooks:
      start:
        - cleanup
    cwd: .
    command: |
      docker build .
      docker run --rm \
        --name webapp \
        --link db \
        -v ${PWD}:/webapp -w /webapp webapp
    environs:
      - POSTGRES_USER=webapp_admin
      - POSTGRES_PASSWORD=db0123
      - POSTGRES_DB=db

  postgres_db:
    ignore_failures: true
    auto_restart: true
    cwd: .
    command: |
      sleep 3
      docker run --rm \
        --name db postgres:12.0-alpine
    environs:
      - POSTGRES_USER=webapp_admin
      - POSTGRES_PASSWORD=db0123
      - POSTGRES_DB=db

  cleanup:
    sub_service: true
    cwd: .
    command: python3 teardown.py

Copyright ©

👤 Hadi Alqattan

📝 License

Copyright © 2020 Hadi Alqattan.
This project is MIT licensed.


Give a ⭐️ if this project helped you!

About

A lightweight services composer written in Golang for managing services (processes) in a development environment.

Topics

Resources

License

Stars

Watchers

Forks

Languages