Giter Site home page Giter Site logo

cronapi's Introduction

cron_api

Table of Contents

Cron API Cluster

This is a Cluster API application for run services. We use it to run list of programs in cluster on independend threads.

Dependencies

After installing Rust, let's download cargo-make for easier application building.

  1. Type in the terminal:
$ cargo install cargo-make

Compilation

  1. When cargo-make is installed, we can compile the project:
$ cargo make build

Run Application

  1. Go into "application/" folder and run binary as:
$ sudo ./cron_api
  1. After the compilation is finished, it should create a folder named application/ with our application and .env static file. (I specifically did not build them inside the binary). We need run as root, because we'll create, and modify crontab.

Application

We start the application by entering the application/ folder and typing ./cron_api in the console. We should get a log like this:

[2023-12-10T22:59:47Z INFO  cron_api] Cron service is already running as root.
[2023-12-10T22:59:47Z INFO  cron_api] Starting server in "0.0.0.0:1726" with 10 threads
[2023-12-10T22:59:47Z INFO  actix_server::builder] starting 10 workers
[2023-12-10T22:59:47Z INFO  actix_server::server] Actix runtime found; starting in Actix runtime

The number of threads depends on the processor from which we launch the API, i.e., the available number of threads - 2. For a 6-core 12-thread processor, this will be 10 threads available for the API handler.

Generate Documentation

  1. For generate and run docuemntation, command in console:
$ cargo doc --no-deps
  1. After finished compile docs, go to the folder target/doc/cron_api/ and open index.html file with your browser.

Endpoints

POST Run

Type [POST]: /run

  1. Endpoint who we use to starting cluster. Incoming object have to be that struct,:
{
    "thread": 2,
    "services": ["service1", "...", "serviceN"],
}
  • where:
    • thread: number
    • services: string[]

POST harmonogram

Type [POST]: /harmonogram

  1. Endpoint to handle harmonogram data. It save harmonogram to file and load it to cron, then current harmonogram is sent to Endpoint on other API to save in DB.
{
  "time": "* * * *",
  "thread": 2,
  "scrapers": ["service1", "service2"]
}
  • where:
    • time: string
    • thread: number
    • scrapers: string[]

cronapi's People

Contributors

apogeum12 avatar

Watchers

 avatar

cronapi's Issues

Configure app

Things to do:

  • - Add dir env in .env file to load of programs
  • - Add optional args for command in .env file
  • - Manualy tests endpoints and cron working
  • - Upgrade README and add example how work app in "video/screenshot"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.