Method: Deadpool::Generator#generate_configuration
- Defined in:
- lib/deadpool/generator.rb
#generate_configuration(options) ⇒ Object
mkdir path/config/pools
path/config/environment.yml
path/config/pools/example.yml
mkdir path/lib/deadpool/monitor
path/lib/deadpool/monitor
mkdir path/lib/deadpool/failover_protocol
path/lib/deadpool/failover_protocol
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/deadpool/generator.rb', line 149 def generate_configuration() config_path = [:config_path] path = config_path FileUtils.mkdir_p(File.join(path, 'config/pools')) FileUtils.mkdir_p(File.join(path, 'lib/deadpool/monitor')) FileUtils.mkdir_p(File.join(path, 'lib/deadpool/failover_protocol')) File.open File.join(path, 'config/pools/example.yml'), 'w' do |file| file.write "pool_name: 'example_database'\nprimary_host: '10.1.2.3'\nsecondary_host: '10.2.3.4'\ncheck_interval: 1\nmax_failed_checks: 10\n\n# There can be only one monitor per pool at this time. The deadpool system\n# defines no rules for the monitor configuration except that it is called\n# monitor_config: and has monitor_class: defined at the base level. \n# All other configuration variables are plugin specific.\nmonitor_config:\n monitor_class: Mysql\n nagios_plugin_path: '/usr/lib/nagios/plugins'\n\n# There can be as many Failover Protocols as you want and you can use \n# the same plugin multiple times. The deadpool defines no riles for the \n# failover protocol config except that it be an array element of \n# failover_protocol_configs and defines protocol_class at it's base. The rest\n# of the configuration is specific to the failover protocol.\nfailover_protocol_configs:\n - protocol_class: EtcHosts\nscript_path: '/usr/local/bin/deadpool_line_modifier'\nservice_host_name: 'master.mysql.example.project.client'\nusername: 'deadpool'\npassword: 'p4ssw0rd'\nuse_sudo: 1\nclient_hosts:\n - '10.3.4.5' # app server 1 (web server)\n - '10.4.5.6' # app server 2 (web server)\n\n - protocol_class: ExecRemoteCommand\ntest_command: '/etc/init.d/nginx status'\nexec_command: '/etc/init.d/nginx restart'\nusername: 'deadpool'\npassword: 'p4ssw0rd'\nuse_sudo: 1\nclient_hosts:\n - '10.3.4.5' # app server 1 (web server)\n - '10.4.5.6' # app server 2 (web server)\n EOF\n end\n \n environment_config_path = File.join(path, 'config/environment.yml')\n environment_conf = <<-EOF\n# log_path: '/var/log/deadpool.log'\n# log_level: INFO\n# system_check_interval: 30\n# admin_hostname: 'localhost'\n# admin_port: 5507\n\n EOF\n # if File.exists? environment_config_path\n # puts \"\#{environment_config_path} already exists. Here's what we would have copied there.\"\n # puts environment_conf\n # else\n unless File.exists? environment_config_path\n File.open environment_config_path, 'w' do |file|\n file.write environment_conf\n end\n end\n \nend\n" |