trampo

0.3.8 • Public • Published

Trampo

Configurable job scheduler through well know file formats

Conventional Commits Build Status Coverage Status Maintainability Known Vulnerabilities Greenkeeper badge

Prerequisities

To run Trampo you will just need to have Nodejs (at least version 8) and NPM installed on your local machine.

Installing

You can install Trampo on your global scope:

npm i -g trampo

Or you can run it directly using npx:

npx trampo -F /path/to/config.json

Config files

Trampo uses JSON files to run the jobs. For now, it has support for 2 kinds of jobs: OneTimeJob and CronJob. They have very similar config files, the only thing that differentiates them, is that one-time job uses the when parameter and the cron job uses the period parameter.

Command Execution

There are 2 things that Trampo can run on the jobs scheduled. It can make an HTTP request or execute a command on your system.

HTTP Request:

{
  url: string;
  method: HttpMethod;
  headers?: object;
  body?: unknown;
  params?: object;
}

Exec:

{
  exec: string;
}

OneTimeJob Example

{
  "when": 10000,
  "exec": "echo \"Hello World\"  >> test.txt ",
  "name": "One time job"
}

CronJobExample

{
  "name": "Cron job",
  "httpRequest": {
    "url": "http://localhost:3000/home",
    "method": "get",
    "params": {
      "hello": "world"
    }
  },
  "period": "* * * * *"
}

Final config file

The final JSON config file that Trampo uses should have a CronJob or a OneTimeJOb or both, wrapped in an array:

[
  {
    "when": 10000,
    "exec": "echo \"Hello World\"  >> test.txt ",
    "name": "One time job"
  },
  {
    "name": "Cron job",
    "httpRequest": {
      "url": "http://localhost:3000/home",
      "method": "get",
      "params": {
        "hello": "world"
      }
    },
    "period": "* * * * *"
  }
]

Running the jobs

To run the jobs using Trampo is easy like that, you build your JSON config file like explained above, they run passing it as the argument:

trampo -F /path/to/config.json
 
or
 
trampo --file /path/to/config.json

Running the tests

Normal tests:

npm run test

Tests with file watch:

npm run test:tdd

Coverage test

npm run test:coverage

Building

npm run build

Built With

  • Typescript
  • Webpack

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Package Sidebar

Install

npm i trampo

Weekly Downloads

1

Version

0.3.8

License

MIT

Unpacked Size

45.9 kB

Total Files

6

Last publish

Collaborators

  • pedromutter