Giter VIP home page Giter VIP logo

no-cron's Introduction

no-cron

CircleCI Build Status Coverage Status Maintainability Test Coverage Known Vulnerabilities contributions welcome License: MPL 2.0 LICENSE 996.icu

A node.js based fake cron. Will run cron jobs with current environment variables.

Usage

Attention

Stop system's cron service before start no-cron, or all cron jobs will be multiple executed.

# Stop system cron service
$ service cron stop
[FAIL] cron is not running ... failed!

Run in Foreground

# Need node.js v8+
$ git clone https://github.com/jerrywdlee/no-cron.git && cd no-cron
$ npm install
$ node cron # This will execute cronjobs in system crontab
$ node cron -f my_cron.txt # Execute cronjobs wrote in a file called `my_cron.txt`

Run as daemon

Plz install pm2 or forever to daemonize no-cron

$ git clone https://github.com/jerrywdlee/no-cron.git && cd no-cron
$ npm i && npm i -g pm2
$ pm2 start cron.js
# OR
$ pm2 start cron.js -- -f my_cron.txt

Docker usage

Some docker example in ./docker directory.

Docker

$ cd docker
$ docker build -t no-cron .
$ docker run no-cron

Docker Compose

$ cd docker
$ docker-compose build
$ docker-compose up

Difference between THE Cron

The Crontab in UNIX/LINUX will run command in an isolated condition. Environment variables such as timezone will be different between cron environment and current environment.

When using time-based job scheduler in docker containers most environment variables will not imported to cron's environment.
PS: Image node:10.15.3-alpine doesn't have this problem, but ruby:2.6.1 does.

Thus, most famous container IaaS providers such as Heroku, recommend users not to use cron inside containers.

But some legacy libraries and projects such as whenever provide easier ways to maintenance time-based job scheduler with in source codes.

So no-cron will give a way to run cron jobs for legacy cron-based libraries or projects. It will parse commands and schedules from crontab, and run them timely with environments as same as main projects.

For alpha stage, I just created a node.js based fack cron for my companies' Rails projects.
Next time, I'll refactor it by Golang or Rust.

Known issues

  • Errors when execute node.js scripts in a different version of node.js

LICENSE

This project is dual licensed under Anti 996 License & Mozilla Public License.

Click here for more info about Anti 996 Project.

Copyright (c) 2019 Jerry Lee

no-cron's People

Contributors

dependabot[bot] avatar jerrywdlee avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.