Class: Luban::Deployment::Service::Base

Inherits:
Package::Base show all
Includes:
Command::Tasks::Control, Command::Tasks::Monitor
Defined in:
lib/luban/deployment/cli/service/base.rb

Constant Summary

Constants included from Command::Tasks::Monitor

Command::Tasks::Monitor::Actions

Constants included from Command::Tasks::Control

Command::Tasks::Control::Actions

Constants included from Command::Tasks::Provision

Command::Tasks::Provision::Actions

Constants included from Parameters::Application

Parameters::Application::DefaultLogrotateInterval, Parameters::Application::DefaultLogrotateMaxAge

Constants included from Parameters::General

Parameters::General::DefaultLubanRootPath

Class Attribute Summary collapse

Attributes inherited from Package::Base

#current_version

Attributes included from Helpers::Configuration

#config

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Command::Tasks::Monitor

#monitor_tasks, #monitorable?

Methods included from Command::Tasks::Control

#control_tasks, #controllable?

Methods inherited from Package::Base

apply_to, #binstubs, #cleanup, decompose_version, dependencies, #find_application, #find_project, get_latest_version, #has_version?, #install, #install_all, latest_version, #monitorable?, package_class, #package_options, required_packages_for, #show_current, #show_summary, #uninstall, #uninstall!, #uninstall_all, #update_package_options, version_mutex, #versions, #whence, #which, worker_class

Methods included from Command::Tasks::Provision

#provision_tasks, #provisionable?

Methods included from Parameters::Application

#env_name, #logrotate_count, #monitor_itself?, #monitorable?

Methods included from Parameters::Base

#parameter

Methods included from Parameters::Project

#monitor_defined?, #process_monitor_via

Methods inherited from Command

#base_templates_path, #controllable?, #default_templates, #default_templates_paths, default_worker_class, #deployable?, dispatch_task, #display_name, #monitorable?, #provisionable?, #run_task, worker_class

Methods included from Parameters::General

included

Methods included from Helpers::Configuration

#ask, #fetch, #find_template_file, #load_configuration_file, #primary, #release_roles, #role, #roles, #server, #set, #set_default, #syntax_error?

Class Attribute Details

.parametersObject (readonly)

Returns the value of attribute parameters.



17
18
19
# File 'lib/luban/deployment/cli/service/base.rb', line 17

def parameters
  @parameters
end

Class Method Details

.inherited(subclass) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/luban/deployment/cli/service/base.rb', line 9

def inherited(subclass)
  super
  # Ensure parameters from base class
  # got inherited to its subclasses
  params = instance_variable_get('@parameters')
  subclass.instance_variable_set('@parameters', params.nil? ? {} : params.clone)
end

.parameter(param, default: nil) ⇒ Object



19
20
21
22
# File 'lib/luban/deployment/cli/service/base.rb', line 19

def parameter(param, default: nil)
  super
  parameters[param] = default
end

.service_action(action, dispatch_to: nil, as: action, locally: false, &blk) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/luban/deployment/cli/service/base.rb', line 24

def service_action(action, dispatch_to: nil, as: action, locally: false, &blk)
  define_method(action) do |args:, opts:|
    if current_version
      send("#{__method__}!", args: args, opts: opts.merge(version: current_version))
    else
      abort "Aborted! No current version of #{display_name} is specified."
    end
  end
  unless dispatch_to.nil?
    dispatch_task "#{action}!", to: dispatch_to, as: as, locally: locally, &blk
    protected "#{action}!"
  end
end

Instance Method Details

#init_profile(args:, opts:) ⇒ Object



49
50
51
# File 'lib/luban/deployment/cli/service/base.rb', line 49

def init_profile(args:, opts:)
  orig_init_profile(args: args, opts: opts.merge(default_templates: default_templates))
end

#orig_init_profileObject



47
# File 'lib/luban/deployment/cli/service/base.rb', line 47

alias_method :orig_init_profile, :init_profile