Class: IISConfig::AppPool

Inherits:
IISObject show all
Defined in:
lib/iisconfig/app_pool.rb

Instance Method Summary collapse

Methods inherited from IISObject

#exist?, #start_provider_exist?

Constructor Details

#initializeAppPool

Returns a new instance of AppPool.



11
12
13
14
15
16
17
18
# File 'lib/iisconfig/app_pool.rb', line 11

def initialize
  @pipeline_mode = :Classic
  @runtime_version = :'v2.0'
  @sites = []
  @ftp_sites = []
  @process_model = ProcessModel.new
  @enable_32bit_app_on_win64 = false
end

Instance Method Details

#addObject



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/iisconfig/app_pool.rb', line 64

def add
  args = []
  args << 'ADD'
  args << 'APPPOOL'
  args << "/name:#{@name}"
  args << "/managedRuntimeVersion:#{@runtime_version}"
  args << "/managedPipelineMode:#{pipeline_mode}"
  if @start_mode
    args << "/startMode:#{@start_mode}"
  end
  args
end

#build_commandsObject



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/iisconfig/app_pool.rb', line 95

def build_commands
  commands = []

  commands << delete if exist? :apppool, @name
  commands << add
  @process_model.settings.each_pair do |key, value|
    safe_command = %W{SET CONFIG /section:applicationPools /[name='#{@name}'].processModel.#{key}:#{value}}

    if value.is_a?(IISConfig::SensitiveValue)
      c = %W{SET CONFIG /section:applicationPools /[name='#{@name}'].processModel.#{key}:#{value.value}}
      commands << IISConfig::Command.new(c, safe_command)
    else
      commands << safe_command
    end
  end
  commands << %W{SET APPPOOL /apppool.name:#{@name} /enable32BitAppOnWin64:#{@enable_32bit_app_on_win64}}

  @sites.each do |s|
    s.app_pool @name.to_sym
    commands += s.build_commands
  end

  @ftp_sites.each do |s|
    s.app_pool @name.to_sym
    commands += s.build_commands
  end

  commands
end

#deleteObject



60
61
62
# File 'lib/iisconfig/app_pool.rb', line 60

def delete
  %W{DELETE APPPOOL #{@name}}
end

#enable_32bit_app_on_win64(value = true) ⇒ Object



35
36
37
# File 'lib/iisconfig/app_pool.rb', line 35

def enable_32bit_app_on_win64(value = true)
  @enable_32bit_app_on_win64 = value
end

#ftp_site(&block) ⇒ Object



52
53
54
# File 'lib/iisconfig/app_pool.rb', line 52

def ftp_site(&block)
  add_instance(@ftp_sites, IISConfig::FtpSite, block)
end

#name(name = nil) ⇒ Object



20
21
22
23
# File 'lib/iisconfig/app_pool.rb', line 20

def name(name = nil)
  @name = name unless name.nil?
  @name
end

#pipeline_mode(mode = nil) ⇒ Object



30
31
32
33
# File 'lib/iisconfig/app_pool.rb', line 30

def pipeline_mode(mode = nil)
  @pipeline_mode = mode unless mode.nil?
  @pipeline_mode
end

#process_model {|@process_model| ... } ⇒ Object

Yields:



44
45
46
# File 'lib/iisconfig/app_pool.rb', line 44

def process_model
  yield @process_model
end

#recycleObject



85
86
87
88
89
90
91
92
93
# File 'lib/iisconfig/app_pool.rb', line 85

def recycle
  args = []
  if exist? :apppool, @name
    args << 'RECYCLE'
    args << 'APPPOOL'
    args << "/apppool.name:#{@name}"
  end
  args
end

#required_pathsObject



77
78
79
80
81
82
83
# File 'lib/iisconfig/app_pool.rb', line 77

def required_paths
  paths = []
  @sites.each do |s|
    paths += s.required_paths
  end
  paths
end

#runtime_version(version = nil) ⇒ Object



25
26
27
28
# File 'lib/iisconfig/app_pool.rb', line 25

def runtime_version(version = nil)
  @runtime_version = version unless version.nil?
  @runtime_version
end

#site(&block) ⇒ Object



48
49
50
# File 'lib/iisconfig/app_pool.rb', line 48

def site(&block)
  add_instance(@sites, IISConfig::Site, block)
end

#sitesObject



56
57
58
# File 'lib/iisconfig/app_pool.rb', line 56

def sites
  @sites
end

#start_mode(value) ⇒ Object



39
40
41
42
# File 'lib/iisconfig/app_pool.rb', line 39

def start_mode(value)
  @start_mode = value
  @start_mode
end