go-task

command module
v0.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2023 License: MIT Imports: 2 Imported by: 0

README

go-task

gtask can manage scheduled and worker tasks.

Config file

workers:
  - id: "task1"
    command: "echo 'task 1'"
  - id: "task2"
    command: "echo 'task 2'"

scheduled:
  - id: "task1"
    expr: "*/5 * * * *"
    command: "echo 'task 1'"
  - id: "task2"
    expr: "0 12 * * *"
    command: "echo 'task 2'"

Usage

Usage:
  gtask [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  help        Help about any command
  schedule    schedule sub commands
  validate    validate config
  version     Show version info
  worker      worker sub commands

Workers
Generate Supervisord config

CLI options:

  • user: Define user who run command
  • working-dir: Define working dir
  • group-name: Define group name (like prefix)
  • output: Define path to save config file
  • format: Choose format of output file
# this command will read gtask.yml and generate supervisord config with workers list.
gtask worker generate --config gtask.yml --group-name my-group --format supervisor --output dest/path.conf
schedule
Run

CLI options:

  • working-dir: Define working dir
  • timezone: Choose a specific timezone
  • no-result-print: Hide output of command
  • result-path: Define path to save output of command
# this command will read gtask.yml and run scheduled tasks (based on cron expr). 
gtask schedule run --config gtask.yml
# or 
gtask schedule run --config gtask.yml --timezone 'Europe/Paris'
Start

CLI options:

  • working-dir: Define working dir
  • timezone: Choose a specific timezone
  • no-result-print: Hide output of command
  • result-path: Define path to save output of command
  • tick: Select duration of each tick
# this command will read gtask.yml and start a daemon that scheduled tasks (based on cron expr). 
gtask schedule start --config gtask.yml
# or 
gtask schedule start --config gtask.yml --timezone 'Europe/Paris' --tick 10m

Requirements

  • golang (1.21+)

Development

  • Install dependencies:

    go mod download
    
  • Generate mocks:

    ./bin/mock.sh
    
  • Build the project:

    go build .
    
  • Run tests:

    go test ./...
    

License

MIT License, see LICENSE.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL