{"id":15642043,"url":"https://github.com/wata727/elastic_whenever","last_synced_at":"2025-05-16T09:05:21.261Z","repository":{"id":25040919,"uuid":"102867693","full_name":"wata727/elastic_whenever","owner":"wata727","description":"Manage ECS Scheduled Tasks like Whenever","archived":false,"fork":false,"pushed_at":"2025-03-24T13:03:46.000Z","size":145,"stargazers_count":70,"open_issues_count":0,"forks_count":21,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-09T11:02:38.763Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/wata727.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null}},"created_at":"2017-09-08T14:03:40.000Z","updated_at":"2025-03-24T13:03:45.000Z","dependencies_parsed_at":"2024-01-03T08:28:07.886Z","dependency_job_id":"3efa2ef4-de27-4d82-bafa-0472c8c7267f","html_url":"https://github.com/wata727/elastic_whenever","commit_stats":{"total_commits":98,"total_committers":11,"mean_commits":8.909090909090908,"dds":0.2857142857142857,"last_synced_commit":"b0bc46c99768d2efede77f50c6f8087a167fbd16"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wata727%2Felastic_whenever","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wata727%2Felastic_whenever/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wata727%2Felastic_whenever/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wata727%2Felastic_whenever/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wata727","download_url":"https://codeload.github.com/wata727/elastic_whenever/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254501557,"owners_count":22081528,"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":[],"created_at":"2024-10-03T11:53:50.546Z","updated_at":"2025-05-16T09:05:16.252Z","avatar_url":"https://github.com/wata727.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Elastic Whenever\n[![Build Status](https://github.com/wata727/elastic_whenever/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/wata727/elastic_whenever/actions)\n[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE.txt)\n[![Gem Version](https://badge.fury.io/rb/elastic_whenever.svg)](https://badge.fury.io/rb/elastic_whenever)\n\nManage ECS scheduled tasks like [Whenever](https://github.com/javan/whenever) gem.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'elastic_whenever'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install elastic_whenever\n\n## Usage\n\nYou can use it almost like Whenever. However, please be aware that you must specify an identifier.\n\n```\n$ elastic_whenever --help\nUsage: elastic_whenever [options]\n    -i, --update identifier          Clear and create scheduled tasks by schedule file\n    -c, --clear identifier           Clear scheduled tasks\n    -l, --list identifier            List scheduled tasks\n    -s, --set variables              Example: --set 'environment=staging'\n        --cluster cluster            ECS cluster to run tasks\n        --task-definition task_definition\n                                     Task definition name, If omit a revision, use the latest revision of the family automatically. Example: --task-definition oneoff-application:2\n        --container container        Container name defined in the task definition\n        --launch-type launch_type    Launch type. EC2 or FARGATE. Default: EC2\n        --assign-public-ip           Assign a public IP. Default: DISABLED (FARGATE only)\n        --security-groups groups     Example: --security-groups 'sg-2c503655,sg-72f0cb0a' (FARGATE only)\n        --subnets subnets            Example: --subnets 'subnet-4973d63f,subnet-45827d1d' (FARGATE only)\n        --platform-version version   Optionally specify the platform version. Default: LATEST (FARGATE only)\n    -f, --file schedule_file         Default: config/schedule.rb\n        --iam-role name              IAM role name used by CloudWatch Events. Default: ecsEventsRole\n        --rule-state state           The state of the CloudWatch Events Rule (ENABLED or DISABLED), default: ENABLED\n        --profile profile_name       AWS shared profile name\n        --access-key aws_access_key_id\n                                     AWS access key ID\n        --secret-key aws_secret_access_key\n                                     AWS secret access key\n        --region region              AWS region\n    -v, --version                    Print version\n    -V, --verbose                    Run rake jobs without --silent\n```\n\nNOTE: Currently, Elastic Whenever supports the Whenever syntax partially. We strongly encourage to use dry-run mode for verifying tasks to be created.\n\n```\n$ elastic_whenever --cluster ecs-test --task-definition example:2 --container cron\ncron(0 3 * * ? *) ecs-test example:2 cron bundle exec rake hoge:run\n\n## [message] Above is your schedule file converted to scheduled tasks; your scheduled tasks was not updated.\n## [message] Run `elastic_whenever --help' for more options.\n```\n\n### Setting variables\nElastic Whenever supports setting variables via the `--set` option [as Whenever does](https://github.com/javan/whenever/wiki/Setting-variables-on-the-fly).\n\nExample:\n\n`elastic_whenever --set 'environment=staging\u0026some_var=foo'`\n\n```ruby\nif @environment == 'staging'\n  every '0 1 * * *' do\n    rake 'some_task_on_staging'\n  end\nelsif @some_var == 'foo'\n  every '0 10 * * *' do\n    rake 'some_task'\n  end\nend\n```\n\nEspecially, `@environment` defaults to `\"production\"`.\n\n## How it works\nElastic Whenever creates CloudWatch Events for every command. Each rule has a one to one mapping to a target.\nfor example, the following input will generate two Rules each with one Target.\n\n```ruby\nevery '0 0 * * *' do\n  rake \"hoge:run\"\n  command \"awesome\"\nend\n```\n\nThe scheduled task's name is a digest value calculated from an identifier, commands, and so on.\n\nNOTE: You should not use the same identifier across different clusters because CloudWatch Events rule names are unique across all clusters.\n\n## Compatibility with Whenever\n### `job_type`\nWhenever supports custom job type with `job_type` method, but Elastic Whenever doesn't support it.\n\n```ruby\n# [warn] Skipping unsupported method: job_type\njob_type :awesome, '/usr/local/bin/awesome :task :fun_level'\n```\n\n### `env`\nWhenever supports environment variables with `env` method, but Elastic Whenever doesn't support it.\nYou should use task definitions to set environment variables.\n\n```ruby\n# [warn] Skipping unsupported method: env\nenv \"VERSION\", \"v1\"\n```\n\n### `:job_template`\nWhenever has a template to describe as cron, but Elastic Whenever doesn't have the template.\nTherefore, `:job_template` option is ignored.\n\n```ruby\nset :job_template, \"/bin/zsh -l -c ':job'\" # ignored\n```\n\n### Frequency\nElastic Whenever processes frequency passed to `every` block almost like Whenever.\n\n```ruby\n# Whenever\n#   0 15 * * * /bin/bash -l -c 'cd /home/user/app \u0026\u0026 RAILS_ENV=production bundle exec rake hoge:run --silent'\n#\n# Elastic Whenever\n#   cron(0 15 * * ? *) ecs-test myapp:2 web bundle exec rake hoge:run --silent\n#\nevery :day, at: \"3:00\" do\n  rake \"hoge:run\"\nend\n\n# Whenever\n#   0,10,20,30,40,50 * * * * /bin/bash -l -c 'awesome'\n#\n# Elastic Whenever\n#   cron(0,10,20,30,40,50 * * * ? *) ecs-test myapp:2 web awesome\n#\nevery 10.minutes do\n  command \"awesome\"\nend\n```\n\nHowever, handling of the day of week is partially different because it follows scheduled expression.\n\n```ruby\n# Whenever\n#   0 0 * * 1 /bin/bash -l -c 'awesome'\n#\n# Elastic Whenever\n#   cron(0 0 ? * 2 *) ecs-test myapp:2 web awesome\n#\nevery :monday do\n  command \"awesome\"\nend\n```\n\nTherefore, cron syntax is converted to scheduled expression like the following:\n\n```ruby\n# cron(0 0 ? * 2 *) ecs-test myapp:2 web awesome\nevery \"0 0 * * 1\" do\n  command \"awesome\"\nend\n```\n\nAbsolutely, you can also write scheduled expression.\n\n```ruby\n# cron(0 0 ? * 2 *) ecs-test myapp:2 web awesome\nevery \"0 0 ? * 2 *\" do\n  command \"awesome\"\nend\n```\n\n#### `:reboot`\nWhenever supports `:reboot` as a cron option, but Elastic Whenever doesn't support it.\n\n```ruby\n# [warn] `reboot` is not supported option. Ignore this task.\nevery :reboot do\n  rake \"hoge:run\"\nend\n```\n\n### Bundle commands\nWhenever checks if the application uses bundler and automatically adds a prefix to commands.\nHowever, Elastic Whenever always adds a prefix on a premise that the application is using bundler.\n\n```ruby\n# Whenever\n#   With bundler    -\u003e bundle exec rake hoge:run\n#   Without bundler -\u003e rake hoge:run\n#\n# Elastic Whenever\n#   bundle exec rake hoge:run\n#\nrake \"hoge:run\"\n```\n\nIf you don't want to add the prefix, set `bundle_command` to empty as follows:\n\n```ruby\nset :bundle_command, \"\"\n```\n\n### Rails\nWhenever supports `runner` job with old Rails versions, but Elastic Whenever supports Rails 4 and above only.\n\n```ruby\n# Whenever\n#   Before them -\u003e script/runner Hoge.run\n#   Rails 3     -\u003e script/rails runner Hoge.run\n#   Rails 4     -\u003e bin/rails runner Hoge.run\n#\n# Elastic Whenever\n#   bin/rails runner Hoge.run\n#\nrunner \"Hoge.run\"\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/wata727/elastic_whenever.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwata727%2Felastic_whenever","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwata727%2Felastic_whenever","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwata727%2Felastic_whenever/lists"}