diff options
author | Thomas Wiest <twiest@users.noreply.github.com> | 2014-12-15 16:07:19 -0500 |
---|---|---|
committer | Thomas Wiest <twiest@users.noreply.github.com> | 2014-12-15 16:07:19 -0500 |
commit | 9830202b133db241493ca3f3d914e1cb1de35963 (patch) | |
tree | 0bb33e5ee852ea533f1f808a8e86e38c97699bb4 /roles/docker_img_monitoring/templates/monitoring_container | |
parent | 2848232bdaed44fadb51548fe9d6c39fe89b8e11 (diff) | |
parent | 023f92f9e3eec7de6c1286549000be79189a4fde (diff) | |
download | openshift-9830202b133db241493ca3f3d914e1cb1de35963.tar.gz openshift-9830202b133db241493ca3f3d914e1cb1de35963.tar.bz2 openshift-9830202b133db241493ca3f3d914e1cb1de35963.tar.xz openshift-9830202b133db241493ca3f3d914e1cb1de35963.zip |
Merge pull request #36 from twiest/pr
changed atomic proxy to use pre-built container images
Diffstat (limited to 'roles/docker_img_monitoring/templates/monitoring_container')
-rwxr-xr-x | roles/docker_img_monitoring/templates/monitoring_container/start.rb.j2 | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/roles/docker_img_monitoring/templates/monitoring_container/start.rb.j2 b/roles/docker_img_monitoring/templates/monitoring_container/start.rb.j2 deleted file mode 100755 index 70d60f87b..000000000 --- a/roles/docker_img_monitoring/templates/monitoring_container/start.rb.j2 +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env ruby - -require 'fileutils' - - -# TODO: These should be passed in as env vars. When we're in a POD, make sure to do this. -# WORKAROUND: ^^ -OO_ENV = '{{ oo_env }}' -OO_CTR_TYPE = 'proxy' -HOSTGROUPS = {{ oo_zabbix_hostgroups | to_nice_json }} -TEMPLATES = ['Template OpenShift Proxy Ctr'] -CTR_NAME = "ctr-#{OO_CTR_TYPE}-#{OO_ENV}-#{ENV['container_uuid'][0..6]}" - - -CTR_CONFIG_FLAG = '/shared/var/run/ctr-ipc/flag/ctr_configured' - - -class Start - def self.wait_for_ctr_configured - while ! File.exist?(CTR_CONFIG_FLAG) - puts "Sleeping 10 seconds, waiting for #{CTR_CONFIG_FLAG}" - sleep 10 - end - end - - def self.add_to_zabbix - # Need to do this as a separate script because /usr/local gets changed after this script starts. - # FIXME: we can change this once we aren't using the puppet container anymore - cmd = "/register-with-zabbix.rb --name #{CTR_NAME}" - cmd += ' ' + HOSTGROUPS.collect() { |a| "--hostgroup '#{a}'" }.join(' ') - cmd += ' ' + TEMPLATES.collect() { |a| "--template '#{a}'" }.join(' ') - puts "Running: #{cmd}" - system(cmd) - raise "failed" unless $?.exitstatus == 0 - end - - def self.setup_shared_dirs - puts '_' - ['/usr/local', '/etc/openshift', '/var/lib/haproxy', '/etc/haproxy'].each do |shared_dir| - puts "Setting up /shared#{shared_dir}..." - FileUtils.rm_rf(shared_dir) - FileUtils.ln_s("/shared#{shared_dir}", shared_dir) - end - puts '_' - end - - def self.setup_cron() - File.open('/etc/crontab', 'a') do |f| - # FIXME: on failure, this should e-mail, not log to a file. Not sure how best to do that in a 1 service per container way. - f.write("30 12 * * * root /usr/bin/flock -n /var/tmp/cron-send-cert-expiration.lock -c '/usr/bin/timeout -s9 30s /usr/local/bin/cron-send-cert-expiration.rb --server noc2.ops.rhcloud.com --zbx-host #{CTR_NAME}' &>> /var/log/cron-send-cert-expiration.log\n") - f.write("*/2 * * * * root /usr/local/bin/cron-send-haproxy-status.rb --server noc2.ops.rhcloud.com --zbx-host #{CTR_NAME} &>> /var/log/cron-send-haproxy-status.log\n") - end - end - - def self.exec_cron() - puts '_' - puts 'Exec-ing cron' - puts '-------------' - puts "Starting cron..." - exec("/usr/sbin/crond -n") - end -end - -if __FILE__ == $0 - $stdout.sync = true - $stderr.sync = true - - Start.setup_shared_dirs() - Start.wait_for_ctr_configured - Start.add_to_zabbix() - Start.setup_cron() - Start.exec_cron() -end |