Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
fix(procfile): route the traffic to web proctype always if its presen…
Browse files Browse the repository at this point in the history
…t in procfile
  • Loading branch information
kmala committed Sep 13, 2016
1 parent 3d3676b commit 60c6a5f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
9 changes: 5 additions & 4 deletions rootfs/api/models/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,13 +627,14 @@ def _check_deployment_in_progress(self, deploys, force_deploy=False):

def _default_structure(self, release):
"""Scale to default structure based on release type"""
# If web in procfile then honor it
if release.build.procfile and 'web' in release.build.procfile:
structure = {'web': 1}

# if there is no SHA, assume a docker image is being promoted
if not release.build.sha:
elif not release.build.sha:
structure = {'cmd': 1}

elif release.build.procfile and 'web' in release.build.procfile:
structure = {'web': 1}

# if a dockerfile, assume docker workflow
elif release.build.dockerfile:
structure = {'cmd': 1}
Expand Down
23 changes: 23 additions & 0 deletions rootfs/api/tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,29 @@ def test_build_default_containers(self, mock_requests):
# pod name is auto generated so use regex
self.assertRegex(container['name'], app_id + '-cmd-[0-9]{8,10}-[a-z0-9]{5}')

# post an image as a build with a procfile
app_id = self.create_app()
# post an image as a build
url = "/v2/apps/{app_id}/builds".format(**locals())
body = {
'image': 'autotest/example',
'procfile': {
'web': 'node worker.js'
}
}
response = self.client.post(url, body)
self.assertEqual(response.status_code, 201, response.data)

url = "/v2/apps/{app_id}/pods/web".format(**locals())
response = self.client.get(url)
self.assertEqual(response.status_code, 200, response.data)
self.assertEqual(len(response.data['results']), 1)
container = response.data['results'][0]
self.assertEqual(container['type'], 'web')
self.assertEqual(container['release'], 'v2')
# pod name is auto generated so use regex
self.assertRegex(container['name'], app_id + '-web-[0-9]{8,10}-[a-z0-9]{5}')

# start with a new app
app_id = self.create_app()
# post a new build with procfile
Expand Down

0 comments on commit 60c6a5f

Please sign in to comment.