Skip to content
This repository was archived by the owner on May 15, 2023. It is now read-only.
/ stewardx Public archive

Scheduled Task Executor With Asynchronous Runtime and Database X

License

Notifications You must be signed in to change notification settings

gokayokyay/stewardx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StewardX

Scheduled Task Executor With Asynchronous Runtime and Database X

Because all the cool stuff have an X...

StewardX is a task scheduler written in pure Rust. By leveraging tokio, it is asynchronous and blazing-fast!

This project is under heavy development, it can (and probably will) break. Please do not use in production yet

Table of Contents

Related repositories

Repository Description
Panel Proof of concept control panel
Documentation Documentation repository
CLI StewardX CLI

Features

  • It's pure Rust and lightweight.
  • Uses PostgreSQL as database to persist the tasks.
  • Has multiple task types, currently it supports command and docker tasks.
  • By leveraging traits, it's a joy to extend StewardX.
  • Supports both Dockerfiles and pre-built Docker images.
  • Has multiple task frequencies, currently it supports cron and hook.
  • Stores outputs of tasks.

Tutorials

Getting Started

Prerequisites

  • Docker (optional)
  • Rust
  • git

Until the prebuilt binaries are released, (Linux x64 binaries are released WOOT 🥳) you can build StewardX on your own. First install the Rust itself by following the instructions on: Rustup Then clone the repository

git clone https://github.com/gokayokyay/stewardx
cd stewardx

If you don't want to use Docker, then please disable the docker feature in Cargo.toml in the root of repository. To disable it, just remove the "docker" item from the default key of [features]. So it'll look like

default = ["panel", "cmd"]

You'll need a running Postgres instance. If you got one, you can skip this step. But if you don't, there're some utility scripts in scripts folder located in the root of the repository. For simplicity's sake, let's just use the temporary one, docker-postgres-temp.sh.

chmod +x ./scripts/docker-postgres-temp.sh
./scripts/docker-postgres-temp.sh

When your instance is up and running, you'll need to state some environment variables.

  • STEWARDX_DATABASE_URL
  • DATABASE_URL - this one won't be required when prebuilt binaries are released. It's required for now because of SQLx.

Let's define those variables:

# Replace the db url with your own if you skipped previos step
export DATABASE_URL=postgresql://postgres:1234@localhost:5432/postgres
export STEWARDX_DATABASE_URL=postgresql://postgres:1234@localhost:5432/postgres

Awesome! Now we just run:

# Note: This may take a while!
cargo build --release

If you get this error:

error: linker `cc` not found

Then install this package (Debian/Ubuntu), then issue the previous command.

sudo apt install build-essential

And while you're at it, you may want to install these packages too:

sudo apt install libssl-dev pkg-config

When to compilation is finished, now you can start StewardX with:

./target/release/stewardx

Now add your first CmdTask with frequency of Hook (Basically a webhook). From another terminal run:

curl --header "Content-Type: application/json" -X POST --data '{"task_name": "My test task", "frequency": "Hook", "task_type": "CmdTask", "task_props": {"command":"echo Hello StewardX!"}}' http://localhost:3000/tasks

This command will output an id, save it somewhere, mine was "08234e0c-63b8-420a-a4fc-80691ca86e17". To execute your previous task, run:

# curl --header "Content-Type: application/json" -X POST http://localhost:3000/#id from previous step
curl --header "Content-Type: application/json" -X POST http://localhost:3000/execute/08234e0c-63b8-420a-a4fc-80691ca86e17

You should get this response:

{"status":"success"}

Awesome! You may be wondering, where's the output of the task? It's easy! In the database. Just run:

curl --header "Content-Type: application/json" http://localhost:3000/task/#your task id#/reports

And you'll get your execution report :)

Roadmap to v1

  • Build a minimal control panel
  • Cover errors
  • Test coverage
  • Write documentation - StewardX Docs
  • Use features to make panel and docker features optional
  • Precompiled binaries (Currently linux only)
  • Create distributed worker system

Roadmap not in order

  • Add websocket support
  • Add one or more task types
  • Create a CLI app - 🥳
  • Create a cute logo - 🥳
  • Create examples
  • Create a landing page
  • Create a GUI controller
  • Ability to delay tasks' execution?

License

Licensed under