Ruby、Rails知识Ruby

一个好用的定时任务管理gem包

2017-06-06  本文已影响57人  dingfj

RoR项目里面一个实用的定时任务处理管理插件。

coro支持Ruby 2.2+, 2.3+, Rails 4.*, 和 Rails 5.*.。


安装使用
 gemfile里面添加gem

     
 执行  bundle install  

        rails generate crono:install
        rake db:migrate

实现安装,安装后会产生app/jobs/ 文件夹,该文件放定时任务文件,

定时job任务写法

config/cronotab.rb  里面写 定时任务的调用

web端查看

添加路由

本地手动启动命令 : bundle exec crono RAILS_ENV=development

本地后台运行命令: bundle exec crono start RAILS_ENV=development
本地后台结束命令: bundle exec crono stop RAILS_ENV=development
⚠️  后台运行需要安装  gem'daemons'

浏览器查看 http://localhost:3000/crono     路由定义的路基

任务管理界面
上一篇 下一篇

猜你喜欢

热点阅读