initialize

in files/gitlab-cookbooks/consul/libraries/watch_helper.rb [34:72]


    def initialize(node)
      @node = node

      
      @enabled_watchers = @node['consul']['watchers']
      @handler_directory = @node['consul']['script_directory']
      @consul_config_directory = @node['consul']['config_dir']

      
      @standard_watchers = [
        Watcher.new(name = node['consul']['internal']['postgresql_service_name'],
                    handler_script = "#{@handler_directory}/failover_postgresql_in_pgbouncer",
                    handler_template = 'failover_pgbouncer.erb',
                    type = 'service',
                    consul_config = @consul_config_directory,
                    template_variables = node['consul'].to_hash.merge({ 'database_name' => node['gitlab']['gitlab_rails']['db_database'] })
                   )
      ]

      
      
      @user_watcher_configs = @node['consul']['watcher_config'] || {}

      @user_watchers = []
      @user_watcher_configs.each do |watcher, config|
        handler = config['handler']
        @user_watchers.push(Watcher.new(name = watcher,
                                        handler_script = "#{@handler_directory}/#{handler}",
                                        handler_template = "#{handler}.erb",
                                        type = 'service',
                                        consul_config = @consul_config_directory,
                                        template_variables = node['consul'].to_hash
                                       )
                           )
      end

      @all_watchers = @standard_watchers + @user_watchers
    end