Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clockworkd

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clockworkd

  • 0.2.5
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Clockworkd - a clock process to replace cron

Cron is non-ideal for running scheduled application tasks, especially in an app deployed to multiple machines. More details.

Clockworkd is a cron replacement. It runs as a lightweight, long-running Ruby process which sits alongside your web processes (Mongrel/Thin) and your worker processes (DJ/Resque/Minion/Stalker) to schedule recurring work at particular times or dates. For example, refreshing feeds on an hourly basis, or send reminder emails on a nightly basis, or generating invoices once a month on the 1st.

Quickstart

Configure application:

In your Gemfile gem "clockworkd", ">= 0.2.5" Run generator to generate config yml and script file Use config/initiaizers to configure options for this gem

Modify clockworkd.yml:

# Run job every two minute: */2 * * * *
clear_sesssion_job:
  cron: "59 1 * * *"
  block: Delayed::Job.enqueue ClearSessionsJob.new
  description: "This job clear sessions table"

Run it as console or daemon application (rails 3.x):

$ ruby script/clockworkd run
$ ruby script/clockworkd --identifier=0 start

Use clockworkd with capistrano:

after "deploy:stop",    "clockworkd:stop"
after "deploy:start",   "clockworkd:start"
after "deploy:restart", "clockworkd:restart"

Use monit script to monitor it:

check process clockworkd
  with pidfile /var/www/apps/{app_name}/shared/pids/clockworkd.pid
  start program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/clockworkd start"
  stop program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/clockworkd stop"

In production

Only one clock process should ever be running across your whole application deployment. For example, if your app is running on three VPS machines (two app servers and one database), your app machines might have the following process topography:

  • App server 1: 3 web (thin start), 3 workers (rake jobs:work), 1 clock (clockwork clock.rb)
  • App server 2: 3 web (thin start), 3 workers (rake jobs:work)

You should use Monit, God, Upstart, or Inittab to keep your clock process running the same way you keep your web and workers running.

Meta

Inspired by

Installation

  • Type 'gem install --local clockworkd' with root account if you have installed RubyGems.

Example

Example goes here.

Copyright (c) 2011 arufanov, released under the MIT license.

FAQs

Package last updated on 16 Oct 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc