Skip to content

prongbang/gocron

Repository files navigation

gocron Docker Pulls Image Size

Gocron manages cron jobs with a configuration.

"Buy Me A Coffee"

Configuration with API

  • docker-compose.yml
services:
  gocron:
    image: prongbang/gocron:latest
    ports:
      - "8000:8000"
    environment:
      - TZ=Asia/Bangkok

Create

  • POST http://localhost:8000/v1/scheduler

Request

{
    "cron": "*/1 * * * *",
    "task": {
        "type": "api",
        "config": {
            "url": "http://localhost/notify",
            "method": "POST",
            "header": {
                "X-API-KEY": "ABC"
            },
            "body": {
                "data": "Hi"
            }
        }
    }
}

Response

{
    "code": "201",
    "message": "Created",
    "data": {
        "job": "83ba2dc9dd5c4326a07dc9eb2d5163b3"
    }
}

Get all

  • GET http://localhost:8000/v1/scheduler

Response

{
    "code": "200",
    "message": "OK",
    "data": [
        {
            "job": "83ba2dc9dd5c4326a07dc9eb2d5163b3",
            "cron": "*/1 * * * *",
            "task": {
                "type": "api",
                "config": {
                    "url": "http://localhost/notify",
                    "method": "POST",
                    "body": {
                      "data": "Hi"
                    },
                    "header": {
                        "X-API-KEY": "ABC"
                    }
                }
            },
            "running": true
        }
    ]
}

Stop

  • POST http://localhost:8000/v1/scheduler/stop

Request

{
    "job": "83ba2dc9dd5c4326a07dc9eb2d5163b3"
}

Response

{
    "code": "200",
    "message": "OK",
    "data": {
        "job": "83ba2dc9dd5c4326a07dc9eb2d5163b3"
    }
}

Configuration with BuildIn

schedulers:
  - job: "every-24-hours"
    cron: "0 0 * * *"
    task:
      url: "http://localhost/post"
      method: "POST"
      body: >
        {"data": "every-24-hours"}
      header: >
        {"X-Api-Key": "XXX"}

Config from File

  • Project structure
project
├── configuration
│     └── configuration.yml
└── docker-compose.yml
  • docker-compose.yml
services:
  gocron:
    image: prongbang/gocron:latest
    environment:
      - TZ=Asia/Bangkok
      - GOCRON_API=true
      - GOCRON_BUILDIN=true
      - GOCRON_SOURCE=file
    volumes:
      - "./configuration.yml:/app/configuration/configuration.yml"

Config from Remote Key/Value Store Example - Encrypted

  • docker-compose.yml
services:
  gocron:
    image: prongbang/gocron:latest
    environment:
      - TZ=Asia/Bangkok
      - GOCRON_BUILDIN=true
      - GOCRON_SOURCE=remote
      - GOCRON_REMOTE_SECURE=true
      - GOCRON_REMOTE_PROVIDER=http://127.0.0.1:4001
      - GOCRON_REMOTE_ENDPOINT=true
      - GOCRON_REMOTE_PATH=/config/hugo.yml
      - GOCRON_REMOTE_SECRET_KEYRING=/etc/secrets/mykeyring.gpg

Config from Remote Key/Value Store Example - Unencrypted

  • docker-compose.yml
services:
  gocron:
    image: prongbang/gocron:latest
    environment:
      - TZ=Asia/Bangkok
      - GOCRON_BUILDIN=true
      - GOCRON_SOURCE=remote
      - GOCRON_REMOTE_SECURE=true
      - GOCRON_REMOTE_PROVIDER=http://127.0.0.1:4001
      - GOCRON_REMOTE_ENDPOINT=true
      - GOCRON_REMOTE_PATH=/config/hugo.yml

About

Gocron manages cron jobs with a configuration.

Resources

License

Stars

Watchers

Forks

Packages

No packages published