Giter Site home page Giter Site logo

ycaihua / minicron Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jamesrwhite/minicron

0.0 3.0 0.0 2.54 MB

A system to manage and monitor cron jobs.

Home Page: https://jamesrwhite.github.io/minicron/

License: GNU General Public License v3.0

Ruby 62.31% Makefile 0.19% Perl 0.06% Nginx 0.64% Shell 0.98% CSS 2.41% JavaScript 8.46% HTML 24.94%

minicron's Introduction

minicron

Build Status Code Climate Dependency Status Inline docs

Looking for an additional maintainer!

Contact me via email or twitter if interested.

minicron aims to complement cron by making it easier to manage and monitor cron jobs, it can largely be thought of as two components that interact together, the CLI and the Hub. The CLI is what is installed on your server(s) and executes your cron command and reports the status back to the Hub. The Hub is the central point where data from one or many instances of the CLI is received and stored in a database. The Hub also provides a web interface to the data and makes it easy to manage your cron jobs.

Screenshots

Background

I initially developed minicron as part of my dissertation at university. The inspiration for developing minicron comes largely from my experience and frustrations using cron, in particular my time spent working at Miniclip (which is where the name comes from, miniclip.. minicron, get it?) where the management and monitoring of cron jobs at times proved to be tricky!

Features

  • Web UI
    • CRUD for cron jobs using ssh
    • GUI for cron schedule create/read/update
    • View realtime output/status as jobs run
    • Historical data for all job executions
  • Alerts when jobs executions are missed or fail via:

Lots more is planned for the future, see open issues or if you don't see the feature you want there add it!

Requirements

OS

Should run on OSX and any Linux/BSD based OS.

Database

Default

  • SQLite

Also Supported

  • MySQL
  • PostgreSQL

Web Server / Reverse Proxy

Nginx

A simple example config for nginx is provided.

Apache

If you're using apache as your reverse proxy you need to ensure you have the following modules installed:

  • libapache2-mod-proxy-html
  • apache2-utils

Run the following to enable them and then restart apache a2enmod proxy proxy_html proxy_http xml2enc

A simple example config for apache is provided.

Installation

minicron is currently under heavy development and I make no gurantees about stability while it remains pre 1.0, as such I would not recommend that you use this in production but I encourage you to give it a try in a non critical environment and help me to improve it and work towards the first stable release.

minicron used to be available to install via Ruby Gems, all future releases (>= 0.8) will no longer be published there and made available as ZIP file releases instead.

Recommended

  1. First check you meet the requirements

  2. Use the handy install script or grab the latest zip/tarball for your OS and install manually.

    bash -c "$(curl -sSL https://raw.githubusercontent.com/jamesrwhite/minicron/master/install.sh)"
    

    ..or build it yourself if you're feeling adventurous!

  3. Set your database configuration options in /etc/minicron.toml, you can use the minicron.toml as a guide on what options are configurable

WARNING

the step below will drop any existing tables in the configured database and create new ones i.e:

DROP TABLE IF EXISTS jobs; CREATE TABLE jobs ..
  1. You can then minicron db setup to create the database schema and run any pending migrations.

  2. Done! See the usage section below for more details on how to use minicron now you have it installed

Docker

You can also run minicron in a docker container, see below for instructions how:

docker pull jamesrwhite/minicron:v0.9.5
minicron_container_id=$(docker run -d -p 127.0.0.1:9292:9292 -i -t jamesrwhite/minicron:v0.9.5)
docker exec $minicron_container_id minicron db setup
docker exec $minicron_container_id minicron server start

Usage

Run a command

minicron run 'mysqldump db > backup.sql'

The global --verbose option can also be passed to the run argument like so

minicron run --verbose ls

You can also run a command in 'dry run' mode to test if it works without sending the output to the server.

minicron run --dry-run 'zip -r backup.zip website'

for further information see minicron help run.

Get help

Running minicron with no arguments is an alias to running minicron help, minicron -h or minicron --help. You can also use the help argument to get information on any command as shown above in the run a command section or alternatively you can pass the -h or --help options like so minicron run -h.

Server

To launch the server (aka the Hub) run

minicron server start

by default it will bind to port 9292 on the host 0.0.0.0 but this can be configured by the command line arguments --host --port and --path or in the config file.

By default the server will run as a daemon with its process id stored in /tmp/minicron.pid you can also use the stop, restart and status commands to control the server.

To run the server in debug mode, so you can see its output and any errors you can pass the --debug option.

See nginx.conf for an example of how to run minicron behind a reverse proxy.

Connecting to a host via SSH

To be able to perform CRUD operations on the crontab minicron needs to connect via SSH to the host. When you set up a host minicron automatically creates a public/private key pair for you and stores it in ~/.ssh on the host the minicron server is being run on using the naming schema minicron_host_*HOST_ID*_rsa(.pub). You will then to add the public key into the remote hosts authorized_keys file.

Version

Like many command line programs minicron will show its version number when the global options -v or --version are passed to the CLI.

Configuration

Some configuration options can be passed in manually but the recommend way to configure minicron is through the use of a config file. You can specify the path to the file using the --config global option. The file is expected to be in the toml format. The default options are specified in the minicron.toml file and minicron will parse a config located in /etc/minicron.toml if it exists. Options specified via the command line will take precedence over those taken from a config file.

Security

As mentioned previously minicron is still under development and as such is missing some essential features as far as security is concerned. For example authentication still needs to be added.

It is not recommended that you allow your minicron host to be accessible via the public internet!

Obviously without authentication anyone who knew the address of your minicron host would be able to set up a potentially malicious job on one of your servers! Future versions may be secure enough to expose publicly but personally I still would not recommend it, minicron is designed to be an internal tool and should be behind a firewall that only allows connections from an internal network and/or a VPN.

Versioning

All stable releases will follow the semantic versioning guidelines. Until 1.0 hits I will try to document any breaking changes in the release descriptions but you should proceed with caution before relying on anything etc etc

Releases will be numbered with the following format:

<major>.<minor>.<patch>

Based on the following guidelines:

  • A new major release indicates a large change where backwards compatibility is broken.
  • A new minor release indicates a normal change that maintains backwards compatibility.
  • A new patch release indicates a bugfix or small change which does not affect compatibility.

Roadmap

I'm going to work out a proper roadmap for the epic journey towards 1.0 in a few weeks when I have more time to focus on this but until then some rough thoughts in no real order..

  • More robust handling of failure in various places/situations
  • Better test coverage for core features
  • More 3rd party alerting integrations
  • REST API
  • Revision control for changes and acitvity tracking
  • Better experience on mobile/tablet
  • Improved security through authentication and permissions
  • Better configuration management
  • Per job configs? Not sure exactly how this would work but it would be handy #82
  • Better performance when lots of data exists in the system (pagination, lazy loading etc)
  • UI improvements, it's just tweaked bootstrap 3 at the moment
  • Various other improvements that hopefully already have issues assigned for them..

Contributing

Feedback and pull requests are welcome, please see CONTRIBUTING.md for more info.

Areas that I would love some help with:

  • Any of the unassigned issues here.
  • General testing of the system, let me know what you think and create issues for any bugs you find!
  • Tests!!
  • Validation and error handling improvements
  • Documentation improvements.
  • Look for 'TODO:' notices littered around the code, I'm trying to convert them all to issues but there are a lot..
  • Code refactoring, I had a deadline to meet for the initial versions so some parts are a tad rushed
  • UI improvements

Support

Where possible I will try and provide support for minicron, you can get in touch with me via:

Or feel free to open an issue and I'll do my best to help.

Credit

minicron makes use of a lot of awesome open source projects that have saved me a lot of time in its development. I started out trying to list all of them but it was taking way too much time so check out the dependencies in minicron.gemspec and app.rb.

License

minicron is licensed under the GPL v3, see here for the full license

minicron's People

Contributors

altitude avatar cyril-bouthors avatar dukex avatar fisadev avatar gabriellhrn avatar gibheer avatar hughbien avatar jamesrwhite avatar jesson avatar magynhard avatar marticr avatar mvlbarcelos avatar padi avatar philippkueng avatar readmecritic avatar remijouannet avatar rrrene avatar sbilly avatar setswei avatar shortjared 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.