README.md
1# Quantum
2
3[Cron](https://en.wikipedia.org/wiki/Cron)-like job scheduler for [Elixir](http://elixir-lang.org/).
4
5[![Hex.pm Version](http://img.shields.io/hexpm/v/quantum.svg)](https://hex.pm/packages/quantum)
6[![Hex docs](http://img.shields.io/badge/hex.pm-docs-green.svg?style=flat)](https://hexdocs.pm/quantum)
7[![Build Status](https://travis-ci.org/c-rack/quantum-elixir.svg?branch=master)](https://travis-ci.org/c-rack/quantum-elixir)
8[![Coverage Status](https://coveralls.io/repos/c-rack/quantum-elixir/badge.svg?branch=master)](https://coveralls.io/r/c-rack/quantum-elixir?branch=master)
9[![Inline docs](http://inch-ci.org/github/c-rack/quantum-elixir.svg)](http://inch-ci.org/github/c-rack/quantum-elixir)
10[![Hex.pm](https://img.shields.io/hexpm/dt/quantum.svg)](https://hex.pm/packages/quantum)
11
12> **This README follows master, which may not be the currently published version**. Here are the
13[docs for the latest published version of Quantum](https://hexdocs.pm/quantum/readme.html).
14
15> :warning: **If you're using a version below `v2.2.6`, please update immediately.** :warning:
16> See [Issue #321](https://github.com/c-rack/quantum-elixir/issues/321) for more details.
17
18## Setup
19
20To use Quantum in your project, edit the `mix.exs` file and add Quantum to
21
22**1. the list of dependencies:**
23```elixir
24defp deps do
25 [{:quantum, "~> 2.2"},
26 {:timex, "~> 3.0"}]
27end
28```
29
30**2. and create a scheduler for your app:**
31```elixir
32defmodule YourApp.Scheduler do
33 use Quantum.Scheduler,
34 otp_app: :your_app
35end
36```
37
38**3. and your application's supervision tree:**
39```elixir
40defmodule YourApp.Application do
41 use Application
42
43 def start(_type, _args) do
44 import Supervisor.Spec, warn: false
45
46 children = [
47 # This is the new line
48 worker(YourApp.Scheduler, [])
49 ]
50
51 opts = [strategy: :one_for_one, name: YourApp.Supervisor]
52 Supervisor.start_link(children, opts)
53 end
54end
55```
56
57## Troubleshooting
58
59To see more transparently what `quantum` is doing, configure the `logger` to display `:debug` messages.
60
61```elixir
62config :logger,
63 level: :debug
64```
65
66If you encounter any problems with `quantum`, please search if there is already an
67 [open issue](https://github.com/c-rack/quantum-elixir/issues) addressing the problem.
68
69Otherwise feel free to [open an issue](https://github.com/c-rack/quantum-elixir/issues/new). Please include debug logs.
70
71## Migrate to V2
72
73See the [Migration Guide](https://hexdocs.pm/quantum/migrate-v2.html).
74
75## Usage
76
77Configure your cronjobs in your `config/config.exs` like this:
78
79```elixir
80config :your_app, YourApp.Scheduler,
81 jobs: [
82 # Every minute
83 {"* * * * *", {Heartbeat, :send, []}},
84 # Every 15 minutes
85 {"*/15 * * * *", fn -> System.cmd("rm", ["/tmp/tmp_"]) end},
86 # Runs on 18, 20, 22, 0, 2, 4, 6:
87 {"0 18-6/2 * * *", fn -> :mnesia.backup('/var/backup/mnesia') end},
88 # Runs every midnight:
89 {"@daily", {Backup, :backup, []}}
90 ]
91```
92
93More details on the usage can be found in the [Documentation](https://hexdocs.pm/quantum/configuration.html)
94
95## Contribution
96
97This project uses the [Collective Code Construction Contract (C4)](http://rfc.zeromq.org/spec:42/C4/) for all code changes.
98
99> "Everyone, without distinction or discrimination, SHALL have an equal right to become a Contributor under the
100terms of this contract."
101
102### tl;dr
103
1041. Check for [open issues](https://github.com/c-rack/quantum-elixir/issues) or [open a new issue](https://github.com/c-rack/quantum-elixir/issues/new) to start a discussion around [a problem](https://www.youtube.com/watch?v=_QF9sFJGJuc).
1052. Issues SHALL be named as "Problem: _description of the problem_".
1063. Fork the [quantum-elixir repository on GitHub](https://github.com/c-rack/quantum-elixir) to start making your changes
1074. If possible, write a test which shows that the problem was solved.
1085. Send a pull request.
1096. Pull requests SHALL be named as "Solution: _description of your solution_"
1107. Your pull request is merged and you are added to the [list of contributors](https://github.com/c-rack/quantum-elixir/graphs/contributors)
111
112## License
113
114[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
115