Class: IISConfig::AppPool

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

Instance Method Summary collapse

Methods inherited from IISObject

#exist?

Constructor Details

#initializeAppPool

Returns a new instance of AppPool.



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

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



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

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



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/iisconfig/app_pool.rb', line 94

def build_commands
  commands = []

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



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

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

#enable_32bit_app_on_win64(value = true) ⇒ Object



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

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

#ftp_site(&block) ⇒ Object



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

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

#name(name = nil) ⇒ Object



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

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

#pipeline_mode(mode = nil) ⇒ Object



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

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

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

Yields:



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

def process_model
  yield @process_model
end

#recycleObject



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

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

#required_pathsObject



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

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

#runtime_version(version = nil) ⇒ Object



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

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

#site(&block) ⇒ Object



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

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

#sitesObject



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

def sites
  @sites
end

#start_mode(value) ⇒ Object



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

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