{"id":13878175,"url":"https://github.com/Ebbe/arask","last_synced_at":"2025-07-16T14:31:33.021Z","repository":{"id":32566598,"uuid":"136470816","full_name":"Ebbe/arask","owner":"Ebbe","description":"Automatic RAils taSKs.","archived":false,"fork":false,"pushed_at":"2024-10-16T12:45:47.000Z","size":128,"stargazers_count":44,"open_issues_count":0,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-13T19:04:23.079Z","etag":null,"topics":["cron","cron-syntax","rails","ruby","ruby-gem","ruby-on-rails"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ebbe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-07T11:59:07.000Z","updated_at":"2024-10-16T12:45:49.000Z","dependencies_parsed_at":"2024-04-02T13:50:30.015Z","dependency_job_id":"20f498e3-58b6-42e1-baa2-a5335f47b5ad","html_url":"https://github.com/Ebbe/arask","commit_stats":{"total_commits":89,"total_committers":3,"mean_commits":"29.666666666666668","dds":0.2584269662921348,"last_synced_commit":"ba4c622950f4f68a043f33b13c2d14d54f3b9cfc"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ebbe%2Farask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ebbe%2Farask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ebbe%2Farask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ebbe%2Farask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ebbe","download_url":"https://codeload.github.com/Ebbe/arask/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226033267,"owners_count":17563125,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cron","cron-syntax","rails","ruby","ruby-gem","ruby-on-rails"],"created_at":"2024-08-06T08:01:41.906Z","updated_at":"2024-11-24T07:30:50.156Z","avatar_url":"https://github.com/Ebbe.png","language":"Ruby","readme":"# Arask\n\n[![Gem Version](https://badge.fury.io/rb/arask.svg)](https://badge.fury.io/rb/arask)\n[![Coverage Status](https://coveralls.io/repos/github/Ebbe/arask/badge.svg?branch=master)](https://coveralls.io/github/Ebbe/arask?branch=master)\n\nAutomatic RAils taSKs (with minimal setup).\n\nNo need to setup anything outside of Rails. If Rails is running, so is Arask. If Rails has been stopped, the next time rails starts, Arask will go through overdue jobs and perform them.\n\nUse cron syntax or simply define the interval.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'arask'\n```\n\nExecute:\n\n```bash\n$ bundle install\n$ rails generate arask:install\n$ rails db:migrate\n```\n\nSetup your tasks in config/initializers/arask.rb. Initially it looks [like this](lib/arask/initialize.rb).\n\n## Usage\n\nAfter installation, you can edit config/initializers/arask.rb with your tasks.\n\n### Examples of jobs in the initializer\n\n```ruby\n# Rake tasks with cron syntax\narask.create task: 'send:logs', cron: '0 2 * * *' # At 02:00 every day\narask.create task: 'update:cache', cron: '*/5 * * * *' # Every 5 minutes\n\n# Scripts with interval (when time of day or month etc doesn't matter)\narask.create script: 'puts \"IM ALIVE!\"', interval: :daily\narask.create task: 'my:awesome_task', interval: :hourly\narask.create task: 'my:awesome_task', interval: 3.minutes\n\n# Run an ActiveJob.\narask.create job: 'ImportCurrenciesJob', interval: 1.month\n\n# Only run on production\narask.create script: 'Attachment.process_new', interval: 5.hours if Rails.env.production?\n\n# Run first time. If the job didn't exist already when starting rails, run it:\narask.create script: 'Attachment.process_new', interval: 5.hours, run_first_time: true\n\n# On exceptions, send email with details\narask.on_exception email: 'errors@example.com'\n\n# Run code on exceptions\narask.on_exception do |exception, arask_job|\n  MyExceptionHandler.new(exception)\nend\n```\n\n### About cron\n\nArask uses [fugit](https://github.com/floraison/fugit) to parse cron and get next execution time. It follows normal cron syntax. You can test your cron at https://crontab.guru/.\n\nNot supported is `@reboot`.\n\n### About interval\n\nThe interval starts when the task has started running. If a task with the interval `:hourly` is run at 08:37PM, then it will run the next time at 09:37PM.\n\n## Todos\n\n- Have a \"try again\" feature. For instance `arask.create script: 'raise \"I failed\"', interval: :daily, fail_retry: 5.minutes, retry_at_most: 2`\n- Be able to specify line and number that failed for an exception:\n\n```ruby\nfile,line,_ = caller.first.split(':')\nfileline = File.readlines(file)[line.to_i - 1].strip\n```\n\n## Special environments\n\n### Heroku\n\nNothing special to setup. But if you use a hobby dyno and it falls to sleep, so will Arask. As soon as the dyno wakes up, Arask will run any pending jobs.\n\n### Docker\n\nNothing special to setup.\n\n## Caveats\n\nIf you reload a database dump, your jobs could be run again.\n\n## Contributing\n\nPlease use https://github.com/Ebbe/arask\n\n## Running tests\n\n```bash\n$ bundle install\n$ bundle exec rake test\n```\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEbbe%2Farask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEbbe%2Farask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEbbe%2Farask/lists"}