cTRL is a server for remote execution of pending tasks and commands in real time, supporting a queue with continuous thread limiting and throttling.

cTRL Logo

Документация на русском: https://github.com/eltaline/ctrl/blob/master/README-RUS.md

cTRL is a server written in Go language that uses a modified version of the NutsDB database, as a backend for a continuous queue of tasks and saving the result of executing commands from given tasks in command interpreters like /bin/bash on servers where this service will be used. Using cTRL, you can receive tasks via the HTTP protocol with commands for executing them on the server and limit the number of simultaneously executed tasks.

Current stable version: 1.1.8

Added in version 1.1.8:

  • Change the time of tasks in queues

Features

  • Multi threading
  • Supports HTTPS and Auth/IP authorization
  • Supported HTTP methods: GET, POST
  • Parallel execution of tasks in realtime
  • Receiving tasks in the queue for deferred parallel execution of commands
  • Limiting the maximum number of threads per virtual host
  • Supports continuous task execution queue
  • Automatic simultaneous execution of only one identical task
  • Supported interpreters: /bin/bash, /bin/sh
  • Supported formats: JSON

Requirements

  • Operating Systems: Linux, BSD, Solaris, OSX
  • Architectures: amd64, arm64, ppc64 and mips64, with only amd64 tested

Real application

We use this server to perform delayed tasks for parallel video conversion using ffmpeg with limiting processes on several video servers with Nvidia GPU, but the server can execute any commands through the shell interpreters. This is a first release.

Documentation

Installation

Install packages or binaries

systemctl enable ctrl && systemctl start ctrl

Configuring and using cTRL server

Default credentials: admin:swordfish

Password generation: echo -n "mypassword" | sha512sum

In most cases it is enough to use the default configuration file. A full description of all product parameters is available here: Options

This guide uses UUIDs. But the client can set task identifiers in any format.

General methods

Run a task or task list in realtime with pending execution

curl -X POST -H "Auth: login:pass" -H "Content-Type: application/json" -d @task.json http://localhost/run

Queuing a task or task list

curl -X POST -H "Auth: login:pass" -H "Content-Type: application/json" -d @task.json http://localhost/task

Getting a task from the received queue

curl -H "Auth: login:pass" "http://localhost/show?key=777a0d24-289e-4615-a439-0bd4efab6103&type=mytype&queue=received"

Getting all tasks from the received queue

curl -H "Auth: login:pass" "http://localhost/show?queue=received"

Getting a task from the working queue

curl -H "Auth: login:pass" "http://localhost/show?key=777a0d24-289e-4615-a439-0bd4efab6103&type=mytype&queue=working"

Getting all tasks from the working queue

curl -H "Auth: login:pass" "http://localhost/show?queue=working"

Getting a task from the list of completed tasks

curl -H "Auth: login:pass" "http://localhost/show?key=777a0d24-289e-4615-a439-0bd4efab6103&type=mytype&queue=completed"

Getting all tasks from the list of completed tasks

curl -H "Auth: login:pass" "http://localhost/show?queue=completed"

Deleting a task from the received queue

curl -H "Auth: login:pass" "http://localhost/del?key=777a0d24-289e-4615-a439-0bd4efab6103&type=mytype&queue=received"

Deleting all tasks from the received queue

curl -H "Auth: login:pass" "http://localhost/del?queue=received"

Deleting a task from the working queue

curl -H "Auth: login:pass" "http://localhost/del?key=777a0d24-289e-4615-a439-0bd4efab6103&type=mytype&queue=working"

Deleting all tasks from the working queue

curl -H "Auth: login:pass" "http://localhost/del?queue=working"

Deleting a task from the list of completed tasks

curl -H "Auth: login:pass" "http://localhost/del?key=777a0d24-289e-4615-a439-0bd4efab6103&type=mytype&queue=completed"

Deleting all tasks from the list of completed tasks

curl -H "Auth: login:pass" "http://localhost/del?queue=completed"

Input format

Description of fields

  • key - an arbitrary unique identifier (colon is not allowed ":")
  • type - arbitrary type of task (colon is not allowed ":")
  • path - path to change the directory before running the command
  • lock - arbitrary lock label
  • command - command
  • threads - the number of threads for a particular type of task
  • timeout - timeout
  • ttltime - task lifetime in completed queue
  • interval - the interval between starting tasks
  • repeaterr - enumeration of errors that require the repeated execution of a task
  • repeatcnt - the number of task reruns in case of any error from parameter repeaterr
  • interr - enumeration of errors that require kill running task
  • intcnt - the number of task reruns in case of any error from parameter interr
  • lookout - enable or disable reaction on errors from stdout
  • replace - overwrite the same task with the same key and the same type in the received queue

Fields threads/ttltime/interval/repeaterr/repeatcnt/interr/intcnt/lookout/replace are relevant only for tasks queued

Examples of setting tasks

Example for one task through /run:

[
{"key":"777a0d24-289e-4615-a439-0bd4efab6103","type":"mytype","path":"/","lock":"mylock1","command":"echo \"hello\" && logger \"hello\" && sleep 5","timeout":15}
]

Example for a task list through /run:

[
{"key":"777a0d24-289e-4615-a439-0bd4efab6103","type":"mytype","path":"/","lock":"mylock1","command":"echo \"hello\" && logger \"hello\" && sleep 5","timeout":15},
{"key":"4964deca-46ff-413f-8a92-e5baefd328e7","type":"mytype","path":"/","lock":"mylock2","command":"echo \"great\" && logger \"great\" && sleep 30","timeout":15},
{"key":"3fdf744d-36f1-499d-bd39-90a004ee39f6","type":"mytype","path":"/","lock":"mylock3","command":"echo \"world\" && logger \"world\" && sleep 15","timeout":15}
]

Example for one task through /task:

[
{"key":"777a0d24-289e-4615-a439-0bd4efab6103","type":"mytype","path":"/","lock":"mylock1","command":"echo \"hello\" && logger \"hello\" && sleep 5","threads":4,"timeout":15,"ttltime":3600,"interval":1,"repeaterr":["CUDA_ERROR_OUT_OF_MEMORY","OtherError"],"repeatcnt":3,"interr":["Generic error in an external library","OtherError"],"intcnt":1,"lookout":false,"replace":false}
]

Example for a task list through /task:

[
{"key":"777a0d24-289e-4615-a439-0bd4efab6103","type":"mytype","path":"/","lock":"mylock1","command":"echo \"hello\" && logger \"hello\" && sleep 5","threads":4,"timeout":15,"ttltime":3600,"interval":1,"repeaterr":["CUDA_ERROR_OUT_OF_MEMORY","OtherError"],"repeatcnt":3,"interr":["Generic error in an external library","OtherError"],"intcnt":1,"lookout":false,"replace":false},
{"key":"4964deca-46ff-413f-8a92-e5baefd328e7","type":"mytype","path":"/","lock":"mylock2","command":"echo \"great\" && logger \"great\" && sleep 30","threads":4,"timeout":15,"ttltime":3600,"interval":1,"repeaterr":["CUDA_ERROR_OUT_OF_MEMORY","OtherError"],"repeatcnt":3,"interr":["Generic error in an external library","OtherError"],"intcnt":1,"lookout":false,"replace":false},
{"key":"3fdf744d-36f1-499d-bd39-90a004ee39f6","type":"mytype","path":"/","lock":"mylock3","command":"echo \"world\" && logger \"world\" && sleep 15","threads":4,"timeout":15,"ttltime":3600,"interval":1,"repeaterr":["CUDA_ERROR_OUT_OF_MEMORY","OtherError"],"repeatcnt":3,"interr":["Generic error in an external library","OtherError"],"intcnt":1,"lookout":false,"replace":false}
]

Output format

Description of fields

  • key - an arbitrary unique identifier
  • time - task receive time
  • type - arbitrary type of task
  • path - path to change the directory before running the command
  • lock - arbitrary lock label
  • command - command
  • threads - the number of threads for a particular type of task
  • timeout - timeout
  • ttltime - task lifetime in completed queue
  • interval - the interval between starting tasks
  • repeaterr - enumeration of errors that require the repeated execution of a task
  • repeatcnt - the number of task reruns in case of any error from parameter repeaterr
  • interr - enumeration of errors that require kill running task
  • intcnt - the number of task reruns in case of any error from parameter interr
  • lookout - enable or disable reaction on errors from stdout
  • replace - overwrite the same task with the same key and the same type in the received queue
  • stdcode - not used at the moment
  • stdout - standard output
  • errcode - error code
  • stderr - standard error output
  • runtime - runtime in milliseconds
  • delcode - error code when deleting a task
  • delerr - error message when deleting a task

Output example

Output of completed tasks:

[
{"key":"777a0d24-289e-4615-a439-0bd4efab6103","time":1589737139,"type":"mytype","path":"/","lock":"mylock1","command":"echo \"hello\" && logger \"hello\" && sleep 5","threads":4,"timeout":15,"ttltime":3600,"interval":1,"repeaterr":["CUDA_ERROR_OUT_OF_MEMORY","OtherError"],"repeatcnt":3,"interr":["Generic error in an external library","OtherError"],"intcnt":1,"lookout":false,"replace":false,"stdcode":0,"stdout":"hello\n","errcode":0,"stderr":"","runtime":10010.669069},
{"key":"4964deca-46ff-413f-8a92-e5baefd328e7","time":1589737139,"type":"mytype","path":"/","lock":"mylock2","command":"echo \"great\" && logger \"great\" && sleep 30","threads":4,"timeout":15,"ttltime":3600,"interval":1,"repeaterr":["CUDA_ERROR_OUT_OF_MEMORY","OtherError"],"repeatcnt":3,"interr":["Generic error in an external library","OtherError"],"intcnt":1,"lookout":false,"replace":false,"stdcode":0,"stdout":"great\n","errcode":124,"stderr":"signal: killed","runtime":15006.034832},
{"key":"3fdf744d-36f1-499d-bd39-90a004ee39f6","time":1589737139,"type":"mytype","path":"/","lock":"mylock3","command":"echo \"world\" && logger \"world\" && sleep 15","threads":4,"timeout":15,"ttltime":3600,"interval":1,"repeaterr":["CUDA_ERROR_OUT_OF_MEMORY","OtherError"],"repeatcnt":3,"interr":["Generic error in an external library","OtherError"],"intcnt":1,"lookout":false,"replace":false,"stdcode":0,"stdout":"world\n","errcode":0,"stderr":"","runtime":15019.839685}
]

Output of deleted tasks:

[
{"key":"777a0d24-289e-4615-a439-0bd4efab6103","time":1589737139,"type":"mytype","path":"/","lock":"mylock1","command":"echo \"hello\" && logger \"hello\" && sleep 5","threads":4,"timeout":15,"ttltime":3600,"interval":1,"repeaterr":["CUDA_ERROR_OUT_OF_MEMORY","OtherError"],"repeatcnt":3,"interr":["Generic error in an external library","OtherError"],"intcnt":1,"lookout":false,"replace":false,"stdcode":0,"stdout":"hello\n","errcode":0,"stderr":"","runtime":10010.669069,"delcode":0,"delerr":""},
{"key":"4964deca-46ff-413f-8a92-e5baefd328e7","time":1589737139,"type":"mytype","path":"/","lock":"mylock2","command":"echo \"great\" && logger \"great\" && sleep 30","threads":4,"timeout":15,"ttltime":3600,"interval":1,"repeaterr":["CUDA_ERROR_OUT_OF_MEMORY","OtherError"],"repeatcnt":3,"interr":["Generic error in an external library","OtherError"],"intcnt":1,"lookout":false,"replace":false,"stdcode":0,"stdout":"great\n","errcode":124,"stderr":"signal: killed","runtime":15006.034832,"delcode":0,"delerr":""},
{"key":"3fdf744d-36f1-499d-bd39-90a004ee39f6","time":1589737139,"type":"mytype","path":"/","lock":"mylock3","command":"echo \"world\" && logger \"world\" && sleep 15","threads":4,"timeout":15,"ttltime":3600,"interval":1,"repeaterr":["CUDA_ERROR_OUT_OF_MEMORY","OtherError"],"repeatcnt":3,"interr":["Generic error in an external library","OtherError"],"intcnt":1,"lookout":false,"replace":false,"stdcode":0,"stdout":"world\n","errcode":0,"stderr":"","runtime":15019.839685,"delcode":0,"delerr":""}
]

Notes and Q&A

  • In key and type, colon is not allowed ":"
  • The limitation of simultaneously running tasks from queue to each virtual host is regulated by the vthreads parameter in the server configuration file or can be overriden through POST method for each type of task
  • The limitation of simultaneously running tasks in realtime to each virtual host is regulated by the rthreads parameter in the server configuration file
  • The key field, if this identifier is the same for two or more different tasks, in this case, when outputting information from the queue, you will receive information on this identifier for several tasks at once, this can be useful for grouping tasks, but they will be from the waiting queue run randomly
  • The type and lock fields, if they are assigned to two or more different tasks, are absolutely identical, in which case the server will perform these tasks from the wait queue in an arbitrary order, but only in turn
  • The type and lock fields set in real time do not matter, but they are required, all tasks will be performed in parallel mode whenever possible.
  • To sequentially execute a list of specific commands related to each other through a waiting queue, install these commands in one task, separated by && or write a shell script
  • Tasks performed in real time are executed parallel.

Error Codes

errcode

  • 0 (no error)
  • 1 (any error)
  • 124 (timeout)
  • 137 (out of memory)
  • 255 (failed to start command)

delcode

  • 0 (no error)
  • 1 (any error)

Todo

  • Any suggestions

Parameters

A full description of all product parameters is available here: Options

HTTP Core

Uses Iris as server http core

Guarantees

No warranty is provided for this software. Please test first

Donations

Contacts

Copyright © 2020 Andrey Kuvshinov. Contacts: <[email protected]>
Copyright © 2020 Eltaline OU. Contacts: <[email protected]>
All rights reserved.
Similar Resources

espnwrapper to track real time scores for your fav match... in a terminal while working.

espnwrapper to track real time scores for your fav match... in a terminal while working.

An espncricinfo wrapper written in go to track scores in real time and in the cmd/cli you can find the Command Line Interface wrapped over this wrapper.

Mar 13, 2022

Continuous Delivery with Spinnaker and Kubernetes

Continuous Delivery with Spinnaker and Kubernetes

Continuous Delivery with Spinnaker and Kubernetes Test Result Tutorial Build App This tutorial takes you through the process of creating a reliable an

Dec 8, 2021

It‘s a cmd-line tool like `make` and `task`, supporting nested args and alias using `cobra`

It‘s a cmd-line tool like `make` and `task`, supporting nested args and alias using `cobra`. It's a makefile alternative and a shell wrapper.

Oct 18, 2022

A Go package for converting RGB and other color formats/colorspaces into DMC thread colors (DMC color name and floss number)

go-c2dmc A Go package for converting RGB and other color formats/colorspaces into DMC thread colors (DMC color name and floss number). Implemented as

Jul 25, 2022

A really basic thread-safe progress bar for Golang applications

A really basic thread-safe progress bar for Golang applications

progressbar A very simple thread-safe progress bar which should work on every OS without problems. I needed a progressbar for croc and everything I tr

Jan 1, 2023

A CLI command to parse Terraform execution result and notify it to Backlog

A CLI command to parse Terraform execution result and notify it to Backlog

tf2b Fork of mercari/tfnotify tf2b parses Terraform commands' execution result and applies it to an arbitrary template and then notifies it to Backlog

Oct 15, 2021

OS Command Execution and Gets the output

OS Command Execution and Gets the output https://stackoverflow.com/questions/24095661/os-exec-sudo-command-in-go/24095983#24095983 https://stackoverfl

Dec 24, 2021

Business Process eXecution Engine

Problem: creating and maintaining robust business systems Creating a proof-of-concept business system is relatively easy. Happy execution path, no cat

Oct 28, 2022

only for creates task and get all tasks from the db.

Todo Rest API This API only creates a task and get all tasks. Table of Contents: Getting Started Requirements Building with Docker API Endpoints and D

Dec 27, 2021
Related tags
painless task queue manager for shell commands with an intuitive cli interface (execute shell commands in distributed cloud-native queue manager).

EXEQ DOCS STILL IN PROGRESS. Execute shell commands in queues via cli or http interface. Features Simple intuitive tiny cli app. Modular queue backend

Dec 14, 2022
Slack remote terminal - execute commands on remote host using slack slash command

slackRT Slack remote terminal - execute commands on remote host using slack slash command Installation Go to api.slack.com/apps and sign in and create

Jul 12, 2022
A simple go program which checks if your websites are running and runs forever (stop it with ctrl+c). It takes two optional arguments, comma separated string with urls and an interval.

uptime A simple go program which checks if your websites are running and runs forever (stop it with ctrl+c). It takes two optional arguments: -interva

Dec 15, 2022
Gracefully quit when you press ctrl-c.

Go - Ctrlc Gracefully quit when you press ctrl-c. Install go get -u github.com/danielgatis/go-ctrlc And then import the package in your code: import "

Apr 23, 2022
Github cli extension to approve or reject pending deployments that are waiting for review.

gh-deploy A gh cli extension to approve or reject pending deployments that are waiting for review. Installation Installation requires a minimum versio

Nov 2, 2022
Tool for shell commands execution, visualization and alerting. Configured with a simple YAML file.
Tool for shell commands execution, visualization and alerting. Configured with a simple YAML file.

Sampler. Visualization for any shell command. Sampler is a tool for shell commands execution, visualization and alerting. Configured with a simple YAM

Dec 28, 2022
Virtualization system for remote code execution.

Delta CLI Command line application for executing source code inside of a container. Build: go build -o ./delta-cli ./main.go Usage: ./delta-cli <path

Nov 20, 2021
Chore is a elegant and simple tool for executing common tasks on remote servers.
Chore is a elegant and simple tool for executing common tasks on remote servers.

Chore is a tool for executing common tasks you run on your remote servers. You can easily setup tasks for deployment, commands, and more.

May 20, 2022
A Go library and common interface for running local and remote commands

go-runcmd go-runcmd is a Go library and common interface for running local and remote commands providing the Runner interface which helps to abstract

Nov 25, 2021
Testing local and remote shell commands in Go

Testing local and remote shell commands in Go. This is an (intentionally simplified) example of how unix shell commands can be unit-tested in Go. The

Nov 30, 2021