class PoiseApplicationPython::Resources::Gunicorn::Resource
Public Instance Methods
port(val)
click to toggle source
Helper to set {#bind} with just a port number.
@param val [String, Integer] Port number to use. @return [void]
# File lib/poise_application_python/resources/gunicorn.rb, line 45 def port(val) bind("0.0.0.0:#{val}") end
Private Instance Methods
default_app_module()
click to toggle source
Compute the default application module to pass to gunicorn. This checks the app state and then looks for commonly used filenames. Raises an exception if no default can be found.
@return [String]
# File lib/poise_application_python/resources/gunicorn.rb, line 56 def default_app_module # If set in app_state, use that. return app_state[:python_wsgi_module] if app_state[:python_wsgi_module] files = Dir.exist?(path) ? Dir.entries(path) : [] # Try to find a known filename. candidate_file = %w{wsgi.py main.py app.py application.py}.find {|file| files.include?(file) } # Try the first Python file. Do I really want this? candidate_file ||= files.find {|file| file.end_with?('.py') } if candidate_file ::File.basename(candidate_file, '.py') else nil end end