marathon-template 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a954fce7f07212d71bd14434522528cebc77ed3
4
- data.tar.gz: 749566187f8ae78e6e85abff6f566c7225b14e98
3
+ metadata.gz: b2ea55fa3b0d54e349149d8377d53f362ff6aa12
4
+ data.tar.gz: cc0675725b9d1da54af378f23f52d629f9cec067
5
5
  SHA512:
6
- metadata.gz: 3c11836e9bcaa8b0e15d9bf62456624c54e9dccc052de27859b12a81dab16da827d241d5c58c4acfed27dc44299cd8ae8c0e29b9c9f62a6b6ff6395e61daedbc
7
- data.tar.gz: 1de8144eeac23b09f4cd5c2d18db3f431413267a2f7dd5f4afd04f42bc0cc556d2a4955fb33e2e04a41accaf160e94da6811cec819df1f87bf2e65cc183f4a4c
6
+ metadata.gz: 605a85748ca6c9a78827efb8cb33e63bcb0d40ba1bc0cd3d616483e1cbcf26c425191fdff40998d863f1c808417c7141be7a3812cd5e827716df24b945134222
7
+ data.tar.gz: 65bd43d891ada88ae4448c06c123eac912e3f65a972f99e9117dd504f22817150abf7adec0cf87104f6a8a765ab33de84d5f7f1ef41685c089eee57c8c934950
@@ -0,0 +1,65 @@
1
+ ---
2
+ # Where is your Marathon?
3
+ marathon: 'http://10.33.100.11:8080'
4
+ # Main HaProxy block
5
+ haproxy:
6
+ global:
7
+ daemon:
8
+ log:
9
+ - '127.0.0.1 local0'
10
+ - '127.0.0.1 local1 notice'
11
+ maxconn: 4096
12
+ defaults:
13
+ log: global
14
+ mode: http
15
+ retries: 3
16
+ maxconn: 2000
17
+ # Any HaProxy param that it utilized more than once can be passed a hash of options
18
+ timeout:
19
+ connect: '5s'
20
+ client: '50s'
21
+ server: '50s'
22
+ http-keep-alive: 1s
23
+ http-request: 15s
24
+ queue: 30s
25
+ tarpit: 60s
26
+ # Or an array of options
27
+ option:
28
+ - httplog
29
+ - dontlognull
30
+ - forwardfor
31
+ - http-server-close
32
+ - redispatch
33
+ # Listen block
34
+ listens:
35
+ stats_test:
36
+ bind: '0.0.0.0:9090'
37
+ mode: http
38
+ stats:
39
+ - enable
40
+ - hide-version
41
+ - 'url /'
42
+ - 'auth admin:admin'
43
+ # Optional server block
44
+ # server:
45
+ # app_name: my_app_name_in_marathon
46
+ # Options to pass into haproxy config on the server line
47
+ # options: check
48
+ #
49
+ # Frontend blocks
50
+ frontends:
51
+ http-in:
52
+ bind: '*:80'
53
+ mode: http
54
+ default_backend: nodes
55
+ # Backend blocks
56
+ backends:
57
+ nodes:
58
+ balance: leastconn
59
+ option: forwardfor
60
+ http-request:
61
+ - 'http-request set-header X-Forwarded-Port %[dst_port]'
62
+ # Backend also accept the server block
63
+ server:
64
+ app_name: my_app_name_in_marathon
65
+ options: check
@@ -144,7 +144,11 @@ module Marathon_template
144
144
  return_hash[task['host']] = task['ports']
145
145
  end
146
146
  else
147
- abort LOG.error "Failed connecting to #{@uri}, response code: #{response.code}"
147
+ if response.code == '404'
148
+ abort LOG.error "Failed connecting to #{marathon_app}, response code: #{response.code}\n Are you sure the app #{app_name} exists?"
149
+ else
150
+ abort LOG.error "Failed connecting to #{marathon_app}, response code: #{response.code}"
151
+ end
148
152
  end
149
153
  return_hash
150
154
  end
@@ -27,18 +27,9 @@ module Marathon_template
27
27
  @config[:haproxy_backends] = config_file['haproxy']['backends'] || nil
28
28
  @config[:haproxy_path] = config_file['haproxy_path'] || '/etc/haproxy'
29
29
  @config[:cron_splay] = config_file['cron_splay_time'] || '* * * * * marathon_template'
30
- # Determine where HaProxy lives
31
- # distro = IO.popen('uname').readlines
32
- # if distro == 'Linux'
33
- # @config[:distro] = distro
34
- # else
35
- # abort "Sorry, #{distro} is not supported."
36
- # end
37
-
38
- # @config.each do |k,v|
39
- # LOG.info("#{k}: #{v}")
40
- # end
41
- @config
30
+ @config.each do |k,v|
31
+ LOG.info("#{k}: #{v}")
32
+ end
42
33
  end
43
34
  end
44
35
  end
@@ -1,5 +1,4 @@
1
1
  #!/bin/env ruby
2
- #$LOAD_PATH << '.'
3
2
  begin
4
3
 
5
4
  require 'rubygems'
@@ -23,10 +22,13 @@ module Marathon_template
23
22
  begin
24
23
  # Set up logging to STDOUT
25
24
  LOG = Logger.new(STDOUT)
26
-
25
+
27
26
  # Get our config file
28
27
  config_path = ENV['MARATHON_TEMPLATE_CONFIG_PATH'] || '/etc/haproxy.yaml'
29
-
28
+ if ! File.exists? config_path
29
+ abort LOG.info "No haproxy yaml configuration found at #{config_path}. Please see https://github.com/malnick/marathon_template/blob/master/ext/haproxy_example.yaml for an example"
30
+ end
31
+
30
32
  # Create a usable hash of configuration
31
33
  CONFIG = Marathon_template::Options.initialize(config_path)
32
34
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marathon-template
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Malnick
@@ -18,6 +18,7 @@ executables:
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
+ - ext/haproxy_example.yaml
21
22
  - lib/marathon_template.rb
22
23
  - lib/marathon-template/deploy.rb
23
24
  - lib/marathon-template/cron.rb