Last active
August 29, 2015 13:56
-
-
Save CoralineAda/9041578 to your computer and use it in GitHub Desktop.
Start a Rails app with conditional features enabled.
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
# Needed to load an application without enabling a certain feature unless I explicitly wanted it. | |
# The use case was not wanting listeners to load unless the server was starting up; otherwise | |
# running rake or any of the rails aliases would fire up the listener which would block the thread. | |
# To complete this thought, check for the value of the environment variable in an initializer, e.g. | |
# | |
# config/initializers/listeners.rb | |
# if ENV['WITH_LISTENERS'] | |
# Rails.logger.info "Starting listeners..." | |
# Listener.start(:customer) | |
# end | |
namespace :startup do | |
task :with_listeners => :environment do | |
puts "Starting application with listeners enabled" | |
system "WITH_LISTENERS=true rails s -p 3010" | |
end | |
task :without_listeners => :environment do | |
puts "Starting application with listeners disabled" | |
system "WITH_LISTENERS=false rails s -p 3010" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment