Created
October 27, 2016 23:24
-
-
Save anicholson/1ec2526edb5a573f9c20a10c54a82bdc to your computer and use it in GitHub Desktop.
Revisions
-
anicholson created this gist
Oct 27, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ #!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require_relative '../config/environment' require 'rack' # Take the whole script down if anything goes remotely wrong Thread.abort_on_exception = true MACCHIATO_PORT = 4000 # Health Check: A rack app that listens on 4000 # and returns 200 to indicate it's alive. _health_check_thread = Thread.new do headers = { 'Content-Type' => 'text/plain' }.freeze response = ['200', headers, 'Alive'].freeze app = proc { |_env| response } Rack::Handler::WEBrick.run app, Port: MACCHIATO_PORT end # Worker Job: A thread that initiates the DelayedJob worker queue. delayed_job_options = { quiet: false }.freeze worker_thread = Thread.new { Delayed::Worker.new(delayed_job_options).start } # Wait for the worker queue thread to finish before ending the script. # If it crashes, the script will end and take the health check thread # down as well. worker_thread.join