{"action":"created","comment":{"url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/pulls/comments/48024735","id":48024735,"diff_hunk":"@@ -0,0 +1,67 @@\n+import os\n+\n+from deploy import Deployer\n+from deployer.compose_commands import DockerComposeInImage\n+from deployer.utility import EnvFile\n+\n+MAX_SCALE_NUMBER = 100\n+\n+\n+class Scaler:\n+    env_file_path = '.env'\n+    secret_env_keys = ['WEBAPP_DJANGO_SECRET_KEY', 'CONVERSION_SERVICE_DJANGO_SECRET_KEY', 'service_user_name', 'service_user_password']\n+    project_name = Deployer.project_name\n+\n+    def __init__(self):\n+        self._bootstrap_check_file = '.bootstrapped'\n+        self._is_bootstrapped = os.path.exists(self._bootstrap_check_file)\n+\n+        self.env = EnvFile(self.env_file_path)\n+        self.compose = DockerComposeInImage(project_name=self.project_name)\n+        assert ' ' not in self.project_name\n+\n+    def scale(self, images, number):\n+        assert len(images) != 0\n+        if self._is_bootstrapped:\n+            self._scale(images_to_scale=images, count=number)\n+        else:\n+            raise RuntimeError('please bootstrap before scaling!')\n+\n+    def _from_env(self):\n+        docker_env = []\n+        for key, value in self.env.get_entries().items():\n+            docker_env.extend(['-e', \"{0}={1}\".format(key, value)])\n+        docker_env.extend(['-e', \"{0}={1}\".format('DEPLOY_VERSION', os.environ['DEPLOY_VERSION'])])\n+        return docker_env\n+\n+    def _scale(self, images_to_scale, count):\n+        extra_env = self._from_env()\n+        for image in images_to_scale:\n+            self.compose.run_compose(['scale', \"{}={}\".format(image, count)], extra_environment_variables=extra_env)\n+\n+if __name__ == '__main__':\n+    import argparse\n+    parser = argparse.ArgumentParser(description='Scale the worker for the osmaxx process.')\n+    parser.add_argument('integer', type=int, help='scale to this number (min. 1, max. {}).'.format(MAX_SCALE_NUMBER))\n+    parser.add_argument(\n+        '--deploy-version',\n+        '-dv',","path":"scale.py","position":48,"original_position":48,"commit_id":"42160f012b0fbf208150e3e15ca0229e25872edc","original_commit_id":"381ef8a809b4148e331e5f313a9431c405a053eb","user":{"login":"das-g","id":97746,"avatar_url":"https://avatars.githubusercontent.com/u/97746?v=3","gravatar_id":"","url":"https://api.github.com/users/das-g","html_url":"https://github.com/das-g","followers_url":"https://api.github.com/users/das-g/followers","following_url":"https://api.github.com/users/das-g/following{/other_user}","gists_url":"https://api.github.com/users/das-g/gists{/gist_id}","starred_url":"https://api.github.com/users/das-g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/das-g/subscriptions","organizations_url":"https://api.github.com/users/das-g/orgs","repos_url":"https://api.github.com/users/das-g/repos","events_url":"https://api.github.com/users/das-g/events{/privacy}","received_events_url":"https://api.github.com/users/das-g/received_events","type":"User","site_admin":false},"body":"`-V` maybe (or is that 'verbose'?)\r\n\r\nDo we need a short option, at all?","created_at":"2015-12-18T13:32:49Z","updated_at":"2015-12-18T13:32:49Z","html_url":"https://github.com/geometalab/osmaxx-deployment-scripts/pull/14#discussion_r48024735","pull_request_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/pulls/14","_links":{"self":{"href":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/pulls/comments/48024735"},"html":{"href":"https://github.com/geometalab/osmaxx-deployment-scripts/pull/14#discussion_r48024735"},"pull_request":{"href":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/pulls/14"}}},"pull_request":{"url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/pulls/14","id":54087483,"html_url":"https://github.com/geometalab/osmaxx-deployment-scripts/pull/14","diff_url":"https://github.com/geometalab/osmaxx-deployment-scripts/pull/14.diff","patch_url":"https://github.com/geometalab/osmaxx-deployment-scripts/pull/14.patch","issue_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/issues/14","number":14,"state":"open","locked":false,"title":"add possibility to scale the worker","user":{"login":"hixi","id":97119,"avatar_url":"https://avatars.githubusercontent.com/u/97119?v=3","gravatar_id":"","url":"https://api.github.com/users/hixi","html_url":"https://github.com/hixi","followers_url":"https://api.github.com/users/hixi/followers","following_url":"https://api.github.com/users/hixi/following{/other_user}","gists_url":"https://api.github.com/users/hixi/gists{/gist_id}","starred_url":"https://api.github.com/users/hixi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hixi/subscriptions","organizations_url":"https://api.github.com/users/hixi/orgs","repos_url":"https://api.github.com/users/hixi/repos","events_url":"https://api.github.com/users/hixi/events{/privacy}","received_events_url":"https://api.github.com/users/hixi/received_events","type":"User","site_admin":false},"body":"Allows to scale the worker processes.\r\n\r\nReviewed by:\r\n- [ ] @das-g \r\n- [ ]  @wasabideveloper \r\n\r\n","created_at":"2015-12-18T10:37:44Z","updated_at":"2015-12-18T13:32:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7fd84bdf6e95597c9b713cdba82e3a888ca19eb6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/pulls/14/commits","review_comments_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/pulls/14/comments","review_comment_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/pulls/comments{/number}","comments_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/issues/14/comments","statuses_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/statuses/42160f012b0fbf208150e3e15ca0229e25872edc","head":{"label":"geometalab:feature/add-scaler","ref":"feature/add-scaler","sha":"42160f012b0fbf208150e3e15ca0229e25872edc","user":{"login":"geometalab","id":8266374,"avatar_url":"https://avatars.githubusercontent.com/u/8266374?v=3","gravatar_id":"","url":"https://api.github.com/users/geometalab","html_url":"https://github.com/geometalab","followers_url":"https://api.github.com/users/geometalab/followers","following_url":"https://api.github.com/users/geometalab/following{/other_user}","gists_url":"https://api.github.com/users/geometalab/gists{/gist_id}","starred_url":"https://api.github.com/users/geometalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geometalab/subscriptions","organizations_url":"https://api.github.com/users/geometalab/orgs","repos_url":"https://api.github.com/users/geometalab/repos","events_url":"https://api.github.com/users/geometalab/events{/privacy}","received_events_url":"https://api.github.com/users/geometalab/received_events","type":"Organization","site_admin":false},"repo":{"id":46783608,"name":"osmaxx-deployment-scripts","full_name":"geometalab/osmaxx-deployment-scripts","owner":{"login":"geometalab","id":8266374,"avatar_url":"https://avatars.githubusercontent.com/u/8266374?v=3","gravatar_id":"","url":"https://api.github.com/users/geometalab","html_url":"https://github.com/geometalab","followers_url":"https://api.github.com/users/geometalab/followers","following_url":"https://api.github.com/users/geometalab/following{/other_user}","gists_url":"https://api.github.com/users/geometalab/gists{/gist_id}","starred_url":"https://api.github.com/users/geometalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geometalab/subscriptions","organizations_url":"https://api.github.com/users/geometalab/orgs","repos_url":"https://api.github.com/users/geometalab/repos","events_url":"https://api.github.com/users/geometalab/events{/privacy}","received_events_url":"https://api.github.com/users/geometalab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/geometalab/osmaxx-deployment-scripts","description":"Deployment scripts for the osmaxx services","fork":false,"url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts","forks_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/forks","keys_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/teams","hooks_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/hooks","issue_events_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/issues/events{/number}","events_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/events","assignees_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/assignees{/user}","branches_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/branches{/branch}","tags_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/tags","blobs_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/git/refs{/sha}","trees_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/statuses/{sha}","languages_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/languages","stargazers_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/stargazers","contributors_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/contributors","subscribers_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/subscribers","subscription_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/subscription","commits_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/commits{/sha}","git_commits_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/git/commits{/sha}","comments_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/comments{/number}","issue_comment_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/issues/comments{/number}","contents_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/contents/{+path}","compare_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/merges","archive_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/downloads","issues_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/issues{/number}","pulls_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/pulls{/number}","milestones_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/milestones{/number}","notifications_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/labels{/name}","releases_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/releases{/id}","created_at":"2015-11-24T10:15:01Z","updated_at":"2015-11-24T15:11:07Z","pushed_at":"2015-12-18T13:19:52Z","git_url":"git://github.com/geometalab/osmaxx-deployment-scripts.git","ssh_url":"git@github.com:geometalab/osmaxx-deployment-scripts.git","clone_url":"https://github.com/geometalab/osmaxx-deployment-scripts.git","svn_url":"https://github.com/geometalab/osmaxx-deployment-scripts","homepage":null,"size":52,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"base":{"label":"geometalab:develop","ref":"develop","sha":"9cd062a7032389e2a57d38a84821ed37b12c4ab1","user":{"login":"geometalab","id":8266374,"avatar_url":"https://avatars.githubusercontent.com/u/8266374?v=3","gravatar_id":"","url":"https://api.github.com/users/geometalab","html_url":"https://github.com/geometalab","followers_url":"https://api.github.com/users/geometalab/followers","following_url":"https://api.github.com/users/geometalab/following{/other_user}","gists_url":"https://api.github.com/users/geometalab/gists{/gist_id}","starred_url":"https://api.github.com/users/geometalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geometalab/subscriptions","organizations_url":"https://api.github.com/users/geometalab/orgs","repos_url":"https://api.github.com/users/geometalab/repos","events_url":"https://api.github.com/users/geometalab/events{/privacy}","received_events_url":"https://api.github.com/users/geometalab/received_events","type":"Organization","site_admin":false},"repo":{"id":46783608,"name":"osmaxx-deployment-scripts","full_name":"geometalab/osmaxx-deployment-scripts","owner":{"login":"geometalab","id":8266374,"avatar_url":"https://avatars.githubusercontent.com/u/8266374?v=3","gravatar_id":"","url":"https://api.github.com/users/geometalab","html_url":"https://github.com/geometalab","followers_url":"https://api.github.com/users/geometalab/followers","following_url":"https://api.github.com/users/geometalab/following{/other_user}","gists_url":"https://api.github.com/users/geometalab/gists{/gist_id}","starred_url":"https://api.github.com/users/geometalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geometalab/subscriptions","organizations_url":"https://api.github.com/users/geometalab/orgs","repos_url":"https://api.github.com/users/geometalab/repos","events_url":"https://api.github.com/users/geometalab/events{/privacy}","received_events_url":"https://api.github.com/users/geometalab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/geometalab/osmaxx-deployment-scripts","description":"Deployment scripts for the osmaxx services","fork":false,"url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts","forks_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/forks","keys_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/teams","hooks_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/hooks","issue_events_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/issues/events{/number}","events_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/events","assignees_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/assignees{/user}","branches_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/branches{/branch}","tags_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/tags","blobs_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/git/refs{/sha}","trees_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/statuses/{sha}","languages_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/languages","stargazers_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/stargazers","contributors_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/contributors","subscribers_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/subscribers","subscription_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/subscription","commits_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/commits{/sha}","git_commits_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/git/commits{/sha}","comments_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/comments{/number}","issue_comment_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/issues/comments{/number}","contents_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/contents/{+path}","compare_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/merges","archive_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/downloads","issues_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/issues{/number}","pulls_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/pulls{/number}","milestones_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/milestones{/number}","notifications_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/labels{/name}","releases_url":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/releases{/id}","created_at":"2015-11-24T10:15:01Z","updated_at":"2015-11-24T15:11:07Z","pushed_at":"2015-12-18T13:19:52Z","git_url":"git://github.com/geometalab/osmaxx-deployment-scripts.git","ssh_url":"git@github.com:geometalab/osmaxx-deployment-scripts.git","clone_url":"https://github.com/geometalab/osmaxx-deployment-scripts.git","svn_url":"https://github.com/geometalab/osmaxx-deployment-scripts","homepage":null,"size":52,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/pulls/14"},"html":{"href":"https://github.com/geometalab/osmaxx-deployment-scripts/pull/14"},"issue":{"href":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/issues/14"},"comments":{"href":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/issues/14/comments"},"review_comments":{"href":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/pulls/14/comments"},"review_comment":{"href":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/pulls/14/commits"},"statuses":{"href":"https://api.github.com/repos/geometalab/osmaxx-deployment-scripts/statuses/42160f012b0fbf208150e3e15ca0229e25872edc"}}}}