Giter VIP home page Giter VIP logo

cronograph's Introduction

Cronograph - Simple Cronjob runner

Overview

Simple Cronjob runner created as a HangFire replacement for the times where you just need an inprocess job execution engine. Hangfire can be found here. Cronograph is easily testable and integrates well into Microsoft.Extensions.DependencyInjection.

Install the Cronograph nuget package using the following command in the package manager console window

PM> Install-Package Cronograph

The Nuget package can be found here

Features

The following features are found in Cronograph:

  • Single process job execution
  • Recurring jobs based on Cron schedules
  • Fire-and-forget jobs
  • Delayed run-once jobs

The following features are NOT found in Cronograph:

  • Scaling out on multiple physical processes and servers
  • Job Continuations
  • Groups/batches of jobs
  • Automatic retries

Usage

In order just to get the simplest cron job up and running in a minimal ASP.NET Core API. Do the following:

using Cronograph;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddCronograph(builder.Configuration);
var app = builder.Build();
var cronograph = app.Services.GetRequiredService<ICronograph>();
cronograph.AddJob("Test job", (cancellationToken) => { Console.WriteLine("Boom!"); return Task.CompletedTask; }, "*/10 * * * * *");
app.Run();

Cronograph also supports cron job classes using the interface IScheduledService. This can be acheived in the following way:

using Cronograph;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddCronograph(builder.Configuration);
var app = builder.Build();
var cronograph = app.Services.GetRequiredService<ICronograph>();
cronograph.AddScheduledService<MyService>("Test service", "*/10 * * * * *");
app.Run();

And with the following scheduled service:

public class MyService : IScheduledService
{
    public Task ExecuteAsync(CancellationToken stoppingToken)
    {
        Console.WriteLine("Scheduled service boom!");
        return Task.CompletedTask;
    }
}

UserInterface

Crongraph has a simple user interface to visualize the jobs currently registred on the system. Add the following NuGET package:

PM> Install-Package Cronograph.UI

And then add the following line of code to your program.cs:

using Cronograph.UI;

var app = builder.Build();
 // Add this..
app.UseCronographUI();

app.Run();

And you should be able to see the user interface on https://YourFantasticMachineAnd:port/Cronograph

Cronograph UI

cronograph's People

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.