class MnoEnterprise::Generators::PumaStackGenerator

Public Instance Methods

copy_monit() click to toggle source
# File lib/generators/mno_enterprise/puma_stack/puma_stack_generator.rb, line 40
def copy_monit
  template "scripts/monit/app-server.conf", "scripts/#{environment}/monit/app-server.conf"
end
copy_nginx() click to toggle source
# File lib/generators/mno_enterprise/puma_stack/puma_stack_generator.rb, line 27
def copy_nginx
  @app_domain = ask("What is the domain pointing to your #{environment} application? [#{default_domain}]")
  @app_domain = default_domain if @app_domain.blank?
  template "scripts/nginx/app", "scripts/#{environment}/nginx/app"
end
copy_setup_script() click to toggle source
# File lib/generators/mno_enterprise/puma_stack/puma_stack_generator.rb, line 23
def copy_setup_script
  template "scripts/setup.sh", "scripts/#{environment}/setup.sh"
end
copy_upstart() click to toggle source
# File lib/generators/mno_enterprise/puma_stack/puma_stack_generator.rb, line 33
def copy_upstart
  template "scripts/upstart/app.conf", "scripts/#{environment}/upstart/app.conf"
  template "scripts/upstart/app-web.conf", "scripts/#{environment}/upstart/app-web.conf"
  template "scripts/upstart/app-web-server.conf", "scripts/#{environment}/upstart/app-web-server.conf"
  template "scripts/upstart/app-web-hotrestart.conf", "scripts/#{environment}/upstart/app-web-hotrestart.conf"
end
install_puma_gem() click to toggle source
# File lib/generators/mno_enterprise/puma_stack/puma_stack_generator.rb, line 16
def install_puma_gem
  gem "puma"
  @num_cpus = ask("How many CPUs (or vCPU for EC2) does your #{environment} machine have? [1]")
  @num_cpus = "1" if @num_cpus.blank?
  template "scripts/puma.rb", "scripts/#{environment}/puma.rb"
end
validate_environment() click to toggle source
# File lib/generators/mno_enterprise/puma_stack/puma_stack_generator.rb, line 10
def validate_environment
  unless available_environments.include?(environment)
    raise Exception.new("Environment '#{environment}' is not defined. Please define this environment in config/environments/#{environment}.rb")
  end
end

Protected Instance Methods

app_name() click to toggle source
# File lib/generators/mno_enterprise/puma_stack/puma_stack_generator.rb, line 49
def app_name
  @app_name ||= Rails.application.class.parent_name.underscore.gsub('_','-')
end
available_environments() click to toggle source
# File lib/generators/mno_enterprise/puma_stack/puma_stack_generator.rb, line 45
def available_environments
  Dir.glob("./config/environments/*.rb").map { |filename| File.basename(filename, ".rb") }
end
default_domain() click to toggle source
# File lib/generators/mno_enterprise/puma_stack/puma_stack_generator.rb, line 53
def default_domain
  @default_domain ||= "#{app_name}-mnoe.maestrano.io"
end