https://github.com/alexose/schedulr

Schedule code to run at a given time. Collect the results in a database.

https://github.com/alexose/schedulr

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.4%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Schedule code to run at a given time. Collect the results in a database.

Basic Info
  • Host: GitHub
  • Owner: alexose
  • Language: Vue
  • Default Branch: main
  • Size: 1.64 MB
Statistics
  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created almost 4 years ago · Last pushed over 1 year ago
Metadata Files
Readme

README.md

Schedulr

Run code in the cloud. Store the results. Get alerted if you want. Designed to run on a single micro instance.

Based on InfluxDB, Bull, and Express.js.

NOTE: This should by no means be used in production. It's just a little tool I wrote on a Sunday afternoon.

Schedulr is primarily useful for web scraping, although it can be used anywhere you may need to get a value and store it for future analysis.

Getting started

git clone https://github.com/alexose/schedulr.git
cd schedulr
npm install
cp config.js.example config.js
<edit config.js as you see fit>
npm run serve 

Usage

The atomic unit of Schedulr is called a Job. At minimum, a Job has two attributes:

code: The javascript code to be run. The return value determines the value to be stored. You can access the previous value via the special tag {{last}}.

frequency: The frequency at which the code should be run, for example '1m' or '4h'. This uses parse-duration under the hood.

TODO: Alerts

Why not just use Lambda, Cloudflare Workers, Google Cloud Run, etc.?

There are a lot of ways to send arbitrary code to the cloud and return a result. However, I've found that the ability to schedule tasks and store their results involes using their clunky UIs. Furthermore, they tend to have opaque billing strategies that make it hard to determine costs ahead of time.

In the future, I may add the ability to use one of these services as a backend, but for now I'm keeping Schedulr as simple as I can.

API Documentation

  • GET /job

Gets a full list of jobs.

  • GET /job/:id

Gets a specific job and its results. By default, this will be limited to the last 1000 results.

  • POST /job

Create a new job.

{ code: "return {{last}} + 1", frequency: "1m", }

  • PUT /job/:id

Edit a job.

You can put a job on a hold like so:

{ pause: true }

  • DELETE /job/:id

Remove a job and all data associated with it.

Examples

const puppeteer = require("puppeteer");

module.exports = async function () {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.goto("https://news.ycombinator.com/");
    let urls = await page.evaluate(() => {
        let results = [];
        let items = document.querySelectorAll("a.titlelink");
        items.forEach(item => {
            results.push({
                url: item.getAttribute("href"),
                text: item.innerText,
            });
        });
        return results;
    });
    browser.close();
    return urls;
}

Owner

  • Name: Alexander Ose
  • Login: alexose
  • Kind: user
  • Location: Jacksonville, Oregon
  • Company: Parse.ly

GitHub Events

Total
  • Push event: 1
Last Year
  • Push event: 1

Dependencies

package-lock.json npm
  • 988 dependencies
package.json npm
  • @babel/core ^7.12.16 development
  • @babel/eslint-parser ^7.12.16 development
  • @vue/cli-plugin-babel ~5.0.0 development
  • @vue/cli-plugin-eslint ~5.0.0 development
  • @vue/cli-service ~5.0.0 development
  • eslint ^7.32.0 development
  • eslint-plugin-vue ^8.0.3 development
  • @influxdata/influxdb-client ^1.29.0
  • ansi-to-html ^0.7.2
  • bull ^4.9.0
  • core-js ^3.8.3
  • dirty-json ^0.9.2
  • express ^4.18.1
  • json-diff ^0.9.0
  • knex ^2.3.0
  • mitt ^3.0.0
  • node-fetch ^2.6.6
  • puppeteer ^17.1.3
  • pushover-notifications ^1.2.2
  • sqlite3 ^5.1.1
  • vm2 ^3.9.11
  • vue ^3.2.13
  • vue-router ^4.1.5
  • vue3-ace-editor ^2.2.2
  • vuejs-ace-editor ^1.0.1
  • ws ^8.9.0