Skip to content

Instantly share code, notes, and snippets.

@norman
Last active November 21, 2019 11:58
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norman/5601554 to your computer and use it in GitHub Desktop.
Save norman/5601554 to your computer and use it in GitHub Desktop.
Delayed Job without Rails
ENV["DATABASE_URL"] = 'postgresql://postgres@localhost/my_database?encoding=utf8'
module Rails
extend self
def root
File.dirname(File.expand_path('..', __FILE__))
end
def logger
@logger ||= Logger.new $stdout
end
end
require 'bundler/setup'
require 'delayed_job'
require 'delayed/command'
require 'active_record'
Delayed::Worker.backend = :active_record
Delayed::Command.new(ARGV).daemonize
source 'https://rubygems.org'
gem 'delayed_job'
gem 'delayed_job_active_record'
gem 'daemons'
gem 'pg'
$ time ./bin/delayed_job start
real 0m2.151s
user 0m1.763s
sys 0m0.343s
$ time ./bin/delayed_job stop
delayed_job: trying to stop process with pid 1337...
delayed_job: process with pid 1337 successfully stopped.
real 0m3.673s
user 0m1.724s
sys 0m0.222s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment