{"action":"created","comment":{"url":"https://api.github.com/repos/praekelt/vumi-go/pulls/comments/26645226","id":26645226,"diff_hunk":"@@ -493,3 +510,32 @@ def getChild(self, name, request):\n     def render_GET(self, request):\n         request.setResponseCode(200)  # OK\n         return ''\n+\n+    @defer.inlineCallbacks\n+    def health_check(self, request):\n+        \"\"\"\n+        We want our health check to be comprehensive, so we implement it here.\n+        \"\"\"\n+        try:\n+            yield self._connection_pool.runQuery(\"SELECT 1\")\n+        except (ConnectionDead, psycopg2.InterfaceError):\n+            request.setResponseCode(503)\n+            request.write(\"Database connection unavailable\\n\")\n+        else:\n+            request.setResponseCode(200)\n+            request.write(\"OK\\n\")\n+        request.finish()\n+\n+\n+def billing_api_resource():\n+    \"\"\"\n+    Create and return a go.billing.api.Root resource for use with twistd.\n+    \"\"\"\n+    connection_string = app_settings.get_connection_string()\n+    connection_pool = DictRowConnectionPool(\n+        None, connection_string, min=app_settings.API_MIN_CONNECTIONS)\n+    resource = Root(connection_pool)\n+    # Tests need to know when we're connected, so stash the deferred on the\n+    # resource for them to look at.\n+    resource._connection_pool_started = connection_pool.start()","path":"go/billing/api.py","position":73,"original_position":73,"commit_id":"e263b04714a89b35fb621896cdb5750bb1f00823","original_commit_id":"8d229ecb5848744b51235303862872a8edbb6840","user":{"login":"jerith","id":43731,"avatar_url":"https://avatars.githubusercontent.com/u/43731?v=3","gravatar_id":"","url":"https://api.github.com/users/jerith","html_url":"https://github.com/jerith","followers_url":"https://api.github.com/users/jerith/followers","following_url":"https://api.github.com/users/jerith/following{/other_user}","gists_url":"https://api.github.com/users/jerith/gists{/gist_id}","starred_url":"https://api.github.com/users/jerith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerith/subscriptions","organizations_url":"https://api.github.com/users/jerith/orgs","repos_url":"https://api.github.com/users/jerith/repos","events_url":"https://api.github.com/users/jerith/events{/privacy}","received_events_url":"https://api.github.com/users/jerith/received_events","type":"User","site_admin":false},"body":"Yes. `twistd` needs a callable that takes no parameters and returns a `Resource` object.","created_at":"2015-03-18T08:37:26Z","updated_at":"2015-03-18T08:37:26Z","html_url":"https://github.com/praekelt/vumi-go/pull/1221#discussion_r26645226","pull_request_url":"https://api.github.com/repos/praekelt/vumi-go/pulls/1221","_links":{"self":{"href":"https://api.github.com/repos/praekelt/vumi-go/pulls/comments/26645226"},"html":{"href":"https://github.com/praekelt/vumi-go/pull/1221#discussion_r26645226"},"pull_request":{"href":"https://api.github.com/repos/praekelt/vumi-go/pulls/1221"}}},"pull_request":{"url":"https://api.github.com/repos/praekelt/vumi-go/pulls/1221","id":30780019,"html_url":"https://github.com/praekelt/vumi-go/pull/1221","diff_url":"https://github.com/praekelt/vumi-go/pull/1221.diff","patch_url":"https://github.com/praekelt/vumi-go/pull/1221.patch","issue_url":"https://api.github.com/repos/praekelt/vumi-go/issues/1221","number":1221,"state":"open","locked":false,"title":"Billing API server needs to get listening port from command line","user":{"login":"jerith","id":43731,"avatar_url":"https://avatars.githubusercontent.com/u/43731?v=3","gravatar_id":"","url":"https://api.github.com/users/jerith","html_url":"https://github.com/jerith","followers_url":"https://api.github.com/users/jerith/followers","following_url":"https://api.github.com/users/jerith/following{/other_user}","gists_url":"https://api.github.com/users/jerith/gists{/gist_id}","starred_url":"https://api.github.com/users/jerith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerith/subscriptions","organizations_url":"https://api.github.com/users/jerith/orgs","repos_url":"https://api.github.com/users/jerith/repos","events_url":"https://api.github.com/users/jerith/events{/privacy}","received_events_url":"https://api.github.com/users/jerith/received_events","type":"User","site_admin":false},"body":"If we want to run multiple billing API servers behind a load balancer, we need to be able to specify the port they listen on from the command line rather than a settings file.","created_at":"2015-03-09T17:07:35Z","updated_at":"2015-03-18T08:37:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f5174a3ea36325c0ec1dce7fe2c671bb038b8cb7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/praekelt/vumi-go/pulls/1221/commits","review_comments_url":"https://api.github.com/repos/praekelt/vumi-go/pulls/1221/comments","review_comment_url":"https://api.github.com/repos/praekelt/vumi-go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/praekelt/vumi-go/issues/1221/comments","statuses_url":"https://api.github.com/repos/praekelt/vumi-go/statuses/e263b04714a89b35fb621896cdb5750bb1f00823","head":{"label":"praekelt:feature/issue-1221-better-billing-api-setup","ref":"feature/issue-1221-better-billing-api-setup","sha":"e263b04714a89b35fb621896cdb5750bb1f00823","user":{"login":"praekelt","id":81810,"avatar_url":"https://avatars.githubusercontent.com/u/81810?v=3","gravatar_id":"","url":"https://api.github.com/users/praekelt","html_url":"https://github.com/praekelt","followers_url":"https://api.github.com/users/praekelt/followers","following_url":"https://api.github.com/users/praekelt/following{/other_user}","gists_url":"https://api.github.com/users/praekelt/gists{/gist_id}","starred_url":"https://api.github.com/users/praekelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekelt/subscriptions","organizations_url":"https://api.github.com/users/praekelt/orgs","repos_url":"https://api.github.com/users/praekelt/repos","events_url":"https://api.github.com/users/praekelt/events{/privacy}","received_events_url":"https://api.github.com/users/praekelt/received_events","type":"Organization","site_admin":false},"repo":{"id":1946622,"name":"vumi-go","full_name":"praekelt/vumi-go","owner":{"login":"praekelt","id":81810,"avatar_url":"https://avatars.githubusercontent.com/u/81810?v=3","gravatar_id":"","url":"https://api.github.com/users/praekelt","html_url":"https://github.com/praekelt","followers_url":"https://api.github.com/users/praekelt/followers","following_url":"https://api.github.com/users/praekelt/following{/other_user}","gists_url":"https://api.github.com/users/praekelt/gists{/gist_id}","starred_url":"https://api.github.com/users/praekelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekelt/subscriptions","organizations_url":"https://api.github.com/users/praekelt/orgs","repos_url":"https://api.github.com/users/praekelt/repos","events_url":"https://api.github.com/users/praekelt/events{/privacy}","received_events_url":"https://api.github.com/users/praekelt/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/praekelt/vumi-go","description":"","fork":false,"url":"https://api.github.com/repos/praekelt/vumi-go","forks_url":"https://api.github.com/repos/praekelt/vumi-go/forks","keys_url":"https://api.github.com/repos/praekelt/vumi-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/praekelt/vumi-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/praekelt/vumi-go/teams","hooks_url":"https://api.github.com/repos/praekelt/vumi-go/hooks","issue_events_url":"https://api.github.com/repos/praekelt/vumi-go/issues/events{/number}","events_url":"https://api.github.com/repos/praekelt/vumi-go/events","assignees_url":"https://api.github.com/repos/praekelt/vumi-go/assignees{/user}","branches_url":"https://api.github.com/repos/praekelt/vumi-go/branches{/branch}","tags_url":"https://api.github.com/repos/praekelt/vumi-go/tags","blobs_url":"https://api.github.com/repos/praekelt/vumi-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/praekelt/vumi-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/praekelt/vumi-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/praekelt/vumi-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/praekelt/vumi-go/statuses/{sha}","languages_url":"https://api.github.com/repos/praekelt/vumi-go/languages","stargazers_url":"https://api.github.com/repos/praekelt/vumi-go/stargazers","contributors_url":"https://api.github.com/repos/praekelt/vumi-go/contributors","subscribers_url":"https://api.github.com/repos/praekelt/vumi-go/subscribers","subscription_url":"https://api.github.com/repos/praekelt/vumi-go/subscription","commits_url":"https://api.github.com/repos/praekelt/vumi-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/praekelt/vumi-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/praekelt/vumi-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/praekelt/vumi-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/praekelt/vumi-go/contents/{+path}","compare_url":"https://api.github.com/repos/praekelt/vumi-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/praekelt/vumi-go/merges","archive_url":"https://api.github.com/repos/praekelt/vumi-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/praekelt/vumi-go/downloads","issues_url":"https://api.github.com/repos/praekelt/vumi-go/issues{/number}","pulls_url":"https://api.github.com/repos/praekelt/vumi-go/pulls{/number}","milestones_url":"https://api.github.com/repos/praekelt/vumi-go/milestones{/number}","notifications_url":"https://api.github.com/repos/praekelt/vumi-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/praekelt/vumi-go/labels{/name}","releases_url":"https://api.github.com/repos/praekelt/vumi-go/releases{/id}","created_at":"2011-06-24T08:46:21Z","updated_at":"2015-03-17T20:32:32Z","pushed_at":"2015-03-18T08:28:48Z","git_url":"git://github.com/praekelt/vumi-go.git","ssh_url":"git@github.com:praekelt/vumi-go.git","clone_url":"https://github.com/praekelt/vumi-go.git","svn_url":"https://github.com/praekelt/vumi-go","homepage":"","size":42479,"stargazers_count":16,"watchers_count":16,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":111,"forks":14,"open_issues":111,"watchers":16,"default_branch":"develop"}},"base":{"label":"praekelt:develop","ref":"develop","sha":"ed28d4e9d9ff1886a465a4b37cbe02fd37f73643","user":{"login":"praekelt","id":81810,"avatar_url":"https://avatars.githubusercontent.com/u/81810?v=3","gravatar_id":"","url":"https://api.github.com/users/praekelt","html_url":"https://github.com/praekelt","followers_url":"https://api.github.com/users/praekelt/followers","following_url":"https://api.github.com/users/praekelt/following{/other_user}","gists_url":"https://api.github.com/users/praekelt/gists{/gist_id}","starred_url":"https://api.github.com/users/praekelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekelt/subscriptions","organizations_url":"https://api.github.com/users/praekelt/orgs","repos_url":"https://api.github.com/users/praekelt/repos","events_url":"https://api.github.com/users/praekelt/events{/privacy}","received_events_url":"https://api.github.com/users/praekelt/received_events","type":"Organization","site_admin":false},"repo":{"id":1946622,"name":"vumi-go","full_name":"praekelt/vumi-go","owner":{"login":"praekelt","id":81810,"avatar_url":"https://avatars.githubusercontent.com/u/81810?v=3","gravatar_id":"","url":"https://api.github.com/users/praekelt","html_url":"https://github.com/praekelt","followers_url":"https://api.github.com/users/praekelt/followers","following_url":"https://api.github.com/users/praekelt/following{/other_user}","gists_url":"https://api.github.com/users/praekelt/gists{/gist_id}","starred_url":"https://api.github.com/users/praekelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekelt/subscriptions","organizations_url":"https://api.github.com/users/praekelt/orgs","repos_url":"https://api.github.com/users/praekelt/repos","events_url":"https://api.github.com/users/praekelt/events{/privacy}","received_events_url":"https://api.github.com/users/praekelt/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/praekelt/vumi-go","description":"","fork":false,"url":"https://api.github.com/repos/praekelt/vumi-go","forks_url":"https://api.github.com/repos/praekelt/vumi-go/forks","keys_url":"https://api.github.com/repos/praekelt/vumi-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/praekelt/vumi-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/praekelt/vumi-go/teams","hooks_url":"https://api.github.com/repos/praekelt/vumi-go/hooks","issue_events_url":"https://api.github.com/repos/praekelt/vumi-go/issues/events{/number}","events_url":"https://api.github.com/repos/praekelt/vumi-go/events","assignees_url":"https://api.github.com/repos/praekelt/vumi-go/assignees{/user}","branches_url":"https://api.github.com/repos/praekelt/vumi-go/branches{/branch}","tags_url":"https://api.github.com/repos/praekelt/vumi-go/tags","blobs_url":"https://api.github.com/repos/praekelt/vumi-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/praekelt/vumi-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/praekelt/vumi-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/praekelt/vumi-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/praekelt/vumi-go/statuses/{sha}","languages_url":"https://api.github.com/repos/praekelt/vumi-go/languages","stargazers_url":"https://api.github.com/repos/praekelt/vumi-go/stargazers","contributors_url":"https://api.github.com/repos/praekelt/vumi-go/contributors","subscribers_url":"https://api.github.com/repos/praekelt/vumi-go/subscribers","subscription_url":"https://api.github.com/repos/praekelt/vumi-go/subscription","commits_url":"https://api.github.com/repos/praekelt/vumi-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/praekelt/vumi-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/praekelt/vumi-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/praekelt/vumi-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/praekelt/vumi-go/contents/{+path}","compare_url":"https://api.github.com/repos/praekelt/vumi-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/praekelt/vumi-go/merges","archive_url":"https://api.github.com/repos/praekelt/vumi-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/praekelt/vumi-go/downloads","issues_url":"https://api.github.com/repos/praekelt/vumi-go/issues{/number}","pulls_url":"https://api.github.com/repos/praekelt/vumi-go/pulls{/number}","milestones_url":"https://api.github.com/repos/praekelt/vumi-go/milestones{/number}","notifications_url":"https://api.github.com/repos/praekelt/vumi-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/praekelt/vumi-go/labels{/name}","releases_url":"https://api.github.com/repos/praekelt/vumi-go/releases{/id}","created_at":"2011-06-24T08:46:21Z","updated_at":"2015-03-17T20:32:32Z","pushed_at":"2015-03-18T08:28:48Z","git_url":"git://github.com/praekelt/vumi-go.git","ssh_url":"git@github.com:praekelt/vumi-go.git","clone_url":"https://github.com/praekelt/vumi-go.git","svn_url":"https://github.com/praekelt/vumi-go","homepage":"","size":42479,"stargazers_count":16,"watchers_count":16,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":111,"forks":14,"open_issues":111,"watchers":16,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/praekelt/vumi-go/pulls/1221"},"html":{"href":"https://github.com/praekelt/vumi-go/pull/1221"},"issue":{"href":"https://api.github.com/repos/praekelt/vumi-go/issues/1221"},"comments":{"href":"https://api.github.com/repos/praekelt/vumi-go/issues/1221/comments"},"review_comments":{"href":"https://api.github.com/repos/praekelt/vumi-go/pulls/1221/comments"},"review_comment":{"href":"https://api.github.com/repos/praekelt/vumi-go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/praekelt/vumi-go/pulls/1221/commits"},"statuses":{"href":"https://api.github.com/repos/praekelt/vumi-go/statuses/e263b04714a89b35fb621896cdb5750bb1f00823"}}}}