Giter Club home page Giter Club logo

app-scheduler's Introduction

NAME

app-scheduler

DESCRIPTION

app-scheduler is an application that manages the scheduled execution of tasks. A task delays until its 'after' event occurs, executes its 'open' actions, delays until the 'before' event occurs, then executes the 'close' actions. If the 'after' and 'before' events are both recurring events, then repeats the cycle again, otherwise the task ends.

'after' and 'before' events can be specified with different kinds of event generation rules. The following rules exist:

timestamp
Specifies an absolute timestamp which can occur at most once.
time-of-day
Specifies a time of day that will recur once each day.
delay
Specifies a delay after the previous event. In the case of a 'after' event this delay will be measured from the start of the task (for the first iteration of the task loop) or from the last 'before' event otherwise. In the case of an 'before' event, this delay will be measured from the time of the last 'after' event.
sunset
Specifies sunset in the local time zone.
sunrise
Specifies sunrise in the local time zone.
dawn
Specifies civil dawn (sun 6 degrees below horizon) in the local time zone.
dusk
Specifies civil dusk (sun 6 degrees below horizon) in the local time zone.

The schedule is passed to the application on startup as its configuration object. The schedule looks like this:

{
    "schedule": [
        {
            "id": "ed9f4064-4f2a-4d1a-8583-c05f19af0b58",
            "description": "Turn on lounge lights for 30 minutes at 19:00",
            "window": {
                "after": {
                    "rule": "time-of-day",
                    "param": "19:00:00"
                },
                "before": {
                    "rule": "delay",
                    "param": "00:30:00"
                }
            },
            "open": [
                {
                    "type": "thing-action",
                    "thingID": "ed9f4064",
                    "action": "turnOn"
                }
            ],
            "close": [
                {
                    "type": "thing-action",
                    "thingID": "ed9f4064",
                    "action": "turnOff"
                }
            ]
        }
    ]
}

A command line utility, nscheduler, can be used to schedule and cancel individual tasks. For example, the task with the above definition would be generated with a nscheduler invocation that looked like this:

nscheduler \
	   --after time-of-day 19:00:00 \
	   --before delay 00:30:00 \
	   --on-open turnOn \
	   --on-close turnOff \
	   --thing ed9f4064 \
	   -- schedule

For more details about the nscheduler command, run nscheduler without any arguments to read some help text.

TOPICS

The scheduler service listens on a topic called:

$site/{siteId}/service/scheduler

It supports the following methods:

schedule {task-model}
cancel {task-id}

app-scheduler's People

Contributors

froz avatar jmanoto avatar jonseymour avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

zymurgybc froz lonc

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.