Last active
November 21, 2019 11:58
-
-
Save norman/5601554 to your computer and use it in GitHub Desktop.
Delayed Job without Rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'delayed_job' | |
gem 'delayed_job_active_record' | |
gem 'daemons' | |
gem 'pg' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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