Skip to content

Instantly share code, notes, and snippets.

@coderanger
Created June 15, 2016 22:31
Show Gist options
  • Save coderanger/962627150d3f3bd17bd2c8014260cee9 to your computer and use it in GitHub Desktop.
Save coderanger/962627150d3f3bd17bd2c8014260cee9 to your computer and use it in GitHub Desktop.
Example of subclassing the Unicorn resource
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