Skip to content

Commit

Permalink
Added instance ID to server line
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Chacon committed Jan 6, 2014
1 parent 0e617f0 commit f0f763c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion elnginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func addInstance(u config.Upstream, i *ec2.Instance) error {
u.Lock()
defer u.Unlock()

upstream := fmt.Sprintf("server %s:80 max_fails=3 fail_timeout=60s;\n", i.PrivateDNSName)
upstream := fmt.Sprintf("server %s:80 max_fails=3 fail_timeout=60s; # %s\n", i.PrivateDNSName, i.InstanceId)
buf := []byte(upstream)

if err := ioutil.WriteFile(filename, buf, 0640); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions elnginx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (s *S) TestReadMessageWithLaunchJSON(c *gocheck.C) {
upstream := Config.Upstreams[0]
content, err := ioutil.ReadFile(upstream.File)
c.Assert(err, gocheck.IsNil)
serverLine := fmt.Sprintf("server %s.internal.invalid:80 max_fails=3 fail_timeout=60s;\n", s.instance_ids[0])
serverLine := fmt.Sprintf("server %s.internal.invalid:80 max_fails=3 fail_timeout=60s; # %s\n", s.instance_ids[0], s.instance_ids[0])
c.Assert(string(content), gocheck.Equals, fmt.Sprintf("upstream %s {\n %s}\n", upstream.Name, serverLine))

// Check run NGINX reload
Expand All @@ -125,7 +125,7 @@ func (s *S) TestAddInstance(c *gocheck.C) {

content, err := ioutil.ReadFile(getUpstreamFilenameForInstance(u, i))
c.Assert(err, gocheck.IsNil)
c.Assert(string(content), gocheck.Equals, "server test.internal:80 max_fails=3 fail_timeout=60s;\n")
c.Assert(string(content), gocheck.Equals, "server test.internal:80 max_fails=3 fail_timeout=60s; # i-00000\n")
}

func (s *S) TestReadMessageWithTerminateJSON(c *gocheck.C) {
Expand Down

0 comments on commit f0f763c

Please sign in to comment.