Created
June 15, 2016 22:31
-
-
Save coderanger/962627150d3f3bd17bd2c8014260cee9 to your computer and use it in GitHub Desktop.
Example of subclassing the Unicorn resource
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
module MyUnicorn | |
# Subclass the resource. | |
class Resource < PoiseApplicationRuby::Resources::Unicorn::Resource | |
# Give it a new name so we can find it. | |
provides(:my_unicorn) | |
# Add a new property. Could do more here. | |
property(:listen) | |
end | |
# Subclass the provider. | |
class Provider < PoiseApplicationRuby::Resources::Unicorn::Provider | |
# Match the name from above. | |
provides(:my_unicorn) | |
# Set service resource options. | |
def service_options(resource) | |
super | |
# Replace the command from the base class. | |
resource.ruby_command("unicorn --listen #{new_resource.listen} #{configru_path}") | |
end | |
end | |
end | |
# Then use the new resource in your recipe. | |
application 'whatever' do | |
my_unicorn do | |
listen '127.0.0.1:8080' | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment