https://github.com/takeyuweb/kyklos
(Probably it is a buggy.) You can use the Amazon CloudWatch Events to schedule jobs on Ruby.
https://github.com/takeyuweb/kyklos
Last synced: over 1 year ago
JSON representation
(Probably it is a buggy.) You can use the Amazon CloudWatch Events to schedule jobs on Ruby.
- Host: GitHub
- URL: https://github.com/takeyuweb/kyklos
- Owner: takeyuweb
- License: mit
- Created: 2016-11-26T14:08:23.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-04-11T05:20:35.000Z (about 2 years ago)
- Last Synced: 2025-02-23T11:04:37.972Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Kyklos
You can use the Amazon CloudWatch Events to schedule jobs on Ruby.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'kyklos'
```
And then execute:
```sh
$ bundle
```
Or install it yourself as:
```sh
$ gem install kyklos
```
## Usage
### 1. Write your config/schedule.rb
```sh
$ vi config/schedule.rb
```
#### Example schedule.rb file
```ruby
cron '0/10 * * * ? *' do
Entry.publish_all
Entry.unpublish_all
end
rate '10 minutes' do
Temporary.destroy_all
end
rate '1 day', as: :recontraction do
Subscription.recontract_all
end
rate '1 day', as: :journalize_events do
Event.journalize
end
```
### 2. Deploy
```sh
bundle exec kyklos -c config/schedule.rb --adapter shoryuken --adapter_args=https://sqs.ap-northeast-1.amazonaws.com/accountid/queue_name
```
#### AWS認証情報について
##### 環境変数として渡す
```sh
$ AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxxx \
> AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \
> AWS_REGION=ap-northeast-1 \
> kyklos -c config/schedule.rb --adapter shoryuken --adapter_args=https://sqs.ap-northeast-1.amazonaws.com/accountid/queue_name
```
##### `aws configure`を使う
```sh
$ aws configure
AWS Access Key ID [None]: xxxxxxxxxxxxxxxxxxxx
AWS Secret Access Key [None]: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Default region name [None]: ap-northeast-1
Default output format [None]: json
$ ls ~/.aws
config credentials
$ kyklos -c config/schedule.rb --adapter shoryuken --adapter_args=https://sqs.ap-northeast-1.amazonaws.com/accountid/queue_name
```
### 3. Shoryuken
#### 設定
```sh
$ vi kyklos_worker.rb
```
```ruby
require 'kyklos'
Kyklos::Adapters::ShoryukenAdapter::Worker.config_path = 'config/schedule.rb'
Shoryuken.register_worker 'queue_name', Kyklos::Adapters::ShoryukenAdapter::Worker
```
```sh
$ vi shoryuken.yml
```
```yaml
concurrency: 25
delay: 25
queues:
- [queue_name, 1]
```
#### ワーカーを開始
```sh
$ bundle exec shoryuken -r ./kyklos_worker.rb -C shoryuken.yml
```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/takeyuweb/kyklos. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).