Module: Wukong::Deploy

Includes:
Plugin
Defined in:
lib/wukong-deploy.rb,
lib/wukong-deploy/repo.rb,
lib/wukong-deploy/console.rb,
lib/wukong-deploy/version.rb,
lib/wukong-deploy/templater.rb,
lib/wukong-deploy/deploy_pack.rb,
lib/wukong-deploy/rake_runner.rb,
lib/wukong-deploy/deploy_runner.rb,
lib/wukong-deploy/templater/differ.rb,
lib/wukong-deploy/templater/messaging.rb,
lib/wukong-deploy/extensions/s3_syncer.rb,
lib/wukong-deploy/extensions/ftp_syncer.rb,
lib/wukong-deploy/extensions/uses_lockfile.rb,
lib/wukong-deploy/extensions/prepare_syncer.rb,
lib/wukong-deploy/extensions/uses_file_state.rb,
lib/wukong-deploy/templater/conflict_resolution.rb,
lib/wukong-deploy/extensions/storm_invocation_override.rb,
lib/wukong-deploy/extensions/hadoop_invocation_override.rb

Overview

Provides some helper methods for loading the assets within a deploy pack at runtime and for Wukong plugins to ask questions about the deploy pack they're running in.

Defined Under Namespace

Modules: ConflictResolution, FTPSyncerOverride, HadoopInvocationOverride, Messaging, PrepareSyncerOverride, S3SyncerOverride, StormInvocationOverride, UsesFileStateOverride, UsesLockfileOverride Classes: Console, DeployRunner, Differ, RakeRunner, Repo, Templater

Constant Summary collapse

VERSION =
'0.2.0'

Class Method Summary collapse

Class Method Details

.app_dirPathname

The directory this deploy pack puts all its application code in.

Returns:

  • (Pathname)


69
70
71
# File 'lib/wukong-deploy/deploy_pack.rb', line 69

def self.app_dir
  root.join('app')
end

.boot(settings, path) ⇒ Object

Boot the deploy pack, reading all available +settings+ and rooting it at the given +path+.

Parameters:

  • settings (Configliere::Param)
  • path (String)


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/wukong-deploy.rb', line 46

def self.boot settings, path
# # Require just enough of wukong-hadoop to give us changes at the
# # processor level.  The rest is only required when running the
# # 'wu-hadoop' program.  Also grab configuration since we'll need it.
# require 'wukong-hadoop/extensions'

# # Grab configuration from Wonderdog.
# require 'wonderdog'

  
  @pre_deploy_settings = settings.dup
  @settings            = settings
  @root                = Pathname.new(path)
  read_common_settings
  read_environment_settings
  read_deploy_settings
  read_remote_settings
  @booted = true
end

.booted?true, false

Has this deploy pack been completely booted, all settings read, &c.

Returns:

  • (true, false)


45
46
47
# File 'lib/wukong-deploy/deploy_pack.rb', line 45

def self.booted?
  @booted
end

.config_dirPathname

The directory this deploy pack uses for configuration files.

Returns:

  • (Pathname)


76
77
78
# File 'lib/wukong-deploy/deploy_pack.rb', line 76

def self.config_dir
  root.join('config')
end

.configure(settings, program) ⇒ Object

Configure the given settings object for use with Wukong::Deploy

Parameters:

  • settings (Configliere::Param)

    the settings to configure

  • program (String)

    the name of the currently executing program



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/wukong-deploy.rb', line 20

def self.configure settings, program
  settings.define(:environment, :description => "The environment to run in", :default => 'development', :flag => 'e', :env_var => 'ICS_PLATFORM_ENV')

  case program
  when 'wu-deploy'
    settings.define(:dry_run, :description => "Don't actually create or modify anything", :type => :boolean, :default => false)
    settings.define(:skip,    :description => "Skip existing files", :type => :boolean, :default => false)
    settings.define(:force,   :description => "Overwrite existing files", :type => :boolean, :default => false)
  when 'wu-hadoop'
    require_relative('wukong-deploy/hadoop_extensions')
    settings[:command_prefix] = 'bundle exec'
  when 'wu-storm'
    require_relative('wukong-deploy/storm_extensions')
    settings[:command_prefix] = 'bundle exec'
  when 'wu-dump'
    require_relative('wukong-deploy/dump_extensions')
  when 'wu-sync', 'wu-sync-all'
    require_relative('wukong-deploy/sync_extensions')
  end
end

.data_dirPathname

The directory this deploy pack keeps local, sample data in.

Returns:

  • (Pathname)


83
84
85
# File 'lib/wukong-deploy/deploy_pack.rb', line 83

def self.data_dir
  root.join('data')
end

.environmentString

Return the current environment the deploy pack is in.

Returns:

  • (String)


30
31
32
# File 'lib/wukong-deploy/deploy_pack.rb', line 30

def self.environment
  settings[:environment]
end

.lib_dirPathname

The directory this deploy pack uses for lib files.

Returns:

  • (Pathname)


90
91
92
# File 'lib/wukong-deploy/deploy_pack.rb', line 90

def self.lib_dir
  root.join('lib')
end

.log_dirPathname

The directory this deploy pack uses for logs.

Returns:

  • (Pathname)


97
98
99
# File 'lib/wukong-deploy/deploy_pack.rb', line 97

def self.log_dir
  root.join('log')
end

.nameObject

Return the name of this deploy pack.



5
6
7
# File 'lib/wukong-deploy/deploy_pack.rb', line 5

def self.name
  settings[:application]
end

.pre_deploy_settingsConfigliere::Param

Return the settings the deploy pack had before it booted itself -- these are used to pass to other tools when invoking them, since they will read the deploy pack settings themselves anyway.

Returns:

  • (Configliere::Param)


55
56
57
# File 'lib/wukong-deploy/deploy_pack.rb', line 55

def self.pre_deploy_settings
  @pre_deploy_settings
end

.require_recursive(glob, ext = '.rb') ⇒ Object

Recursively require each Ruby file +dir+.

Examples:

Requiring all .rb files anywhere within /lib/my_lib


Wukong::Deploy.require_recursive("lib/my_lib")

Parameters:

  • glob (String)


23
24
25
# File 'lib/wukong-deploy/deploy_pack.rb', line 23

def self.require_recursive glob, ext='.rb'
  Dir[root.join("#{glob}/**/*#{ext}")].each { |path| require(path) }
end

.rootPathname

The root directory of this deploy pack.

Returns:

  • (Pathname)


12
13
14
# File 'lib/wukong-deploy/deploy_pack.rb', line 12

def self.root
  @root
end

.script_dirPathname

The directory this deploy pack puts all its scripts in.

Returns:

  • (Pathname)


104
105
106
# File 'lib/wukong-deploy/deploy_pack.rb', line 104

def self.script_dir
  root.join('script')
end

.settingsConfigliere::Param

Return the deploy pack's own settings.

Returns:

  • (Configliere::Param)


37
38
39
# File 'lib/wukong-deploy/deploy_pack.rb', line 37

def self.settings
  @settings
end

.spec_dirPathname

The directory this deploy pack puts all its Ruby unit tests.

Returns:

  • (Pathname)


111
112
113
# File 'lib/wukong-deploy/deploy_pack.rb', line 111

def self.spec_dir
  root.join('spec')
end

.src_dirPathname

The directory this deploy pack puts all its non-Ruby source code.

Returns:

  • (Pathname)


119
120
121
# File 'lib/wukong-deploy/deploy_pack.rb', line 119

def self.src_dir
  root.join('src')
end

.tmp_dirPathname

The directory this deploy pack uses for temporary files.

Returns:

  • (Pathname)


126
127
128
# File 'lib/wukong-deploy/deploy_pack.rb', line 126

def self.tmp_dir
  root.join('tmp')
end