We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
s3.upload returns `Location: http://localhost:4566`
# Bug report

# Detailed description

The `AWS.s3.upload()` (official SDK - https://github.com/aws/aws-sdk-js) returns an object with the `Location` key that points to 4566 instead of 4572 (LocalStack S3 port).

## Expected behavior

The `Location` should point to the file on S3.

Example:

```
Location: http://localhost:4572/path/to/bucket.txt
```

## Actual behavior

The `Location` points to the LocalStack entrypoint.

Example:

```
Location: http://localhost:4566/path/to/bucket.txt
```

# Steps to reproduce

- Upload a file to S3 using the official AWS SDK (https://github.com/aws/aws-sdk-js).
- Check out the `Location` property.

## Client code

```javascript
const AWS = require('aws-sdk');
const s3 = new AWS.S3({
  region: 'us-west-1',
  endpoint: 'http://localhost:4566',
  apiVersion: '2006-03-01',
  s3ForcePathStyle: true,
});

(async () => {
  await s3
    .createBucket({ Bucket: 'my-bucket', ACL: 'private' })
    .promise();

  const { Location } = await s3
    .upload({ Key: 'file.txt', Body: 'test', Bucket: 'my-bucket' })
    .promise();

  console.assert(Location === 'http://localhost:4572/my-bucket/file.txt');
})();
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `localstack/services/edge.py`
Content:
```
1 import re
2 import os
3 import sys
4 import json
5 import logging
6 from requests.models import Response
7 from localstack import config
8 from localstack.constants import HEADER_LOCALSTACK_TARGET, HEADER_LOCALSTACK_EDGE_URL, LOCALSTACK_ROOT_FOLDER
9 from localstack.utils.common import run, is_root, TMP_THREADS
10 from localstack.utils.common import safe_requests as requests
11 from localstack.services.generic_proxy import ProxyListener, GenericProxy
12 
13 LOG = logging.getLogger(__name__)
14 
15 # Header to indicate that the process should kill itself. This is required because if
16 # this process is started as root, then we cannot kill it from a non-root process
17 HEADER_KILL_SIGNAL = 'x-localstack-kill'
18 
19 
20 class ProxyListenerEdge(ProxyListener):
21 
22     def forward_request(self, method, path, data, headers):
23         if method == 'OPTIONS':
24             return 200
25 
26         # kill the process if we receive this header
27         headers.get(HEADER_KILL_SIGNAL) and os._exit(0)
28 
29         target = headers.get('x-amz-target', '')
30         auth_header = headers.get('authorization', '')
31         host = headers.get('host', '')
32         headers[HEADER_LOCALSTACK_EDGE_URL] = 'https://%s' % host
33 
34         # extract API details
35         _, port, path, host = get_api_from_headers(headers, path)
36 
37         if not port:
38             # detect S3 presigned URLs
39             if 'AWSAccessKeyId=' in path or 'Signature=' in path:
40                 port = config.PORT_S3
41 
42         if not port:
43             LOG.info('Unable to find forwarding rule for host "%s", path "%s", target header "%s", auth header "%s"' %
44                      (host, path, target, auth_header))
45             response = Response()
46             response.status_code = 404
47             response._content = '{"status": "running"}'
48             return response
49 
50         use_ssl = config.USE_SSL
51 
52         connect_host = '%s:%s' % (config.HOSTNAME, port)
53         url = 'http%s://%s%s' % ('s' if use_ssl else '', connect_host, path)
54         headers['Host'] = host
55         function = getattr(requests, method.lower())
56         if isinstance(data, dict):
57             data = json.dumps(data)
58 
59         response = function(url, data=data, headers=headers, verify=False)
60         return response
61 
62 
63 def get_api_from_headers(headers, path=None):
64     target = headers.get('x-amz-target', '')
65     host = headers.get('host', '')
66     auth_header = headers.get('authorization', '')
67     ls_target = headers.get(HEADER_LOCALSTACK_TARGET, '')
68     path = path or '/'
69 
70     # initialize result
71     result = '_unknown_', 0
72 
73     # https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html
74     try:
75         credential_scope = auth_header.split(',')[0].split()[1]
76         _, _, _, service, _ = credential_scope.split('/')
77         result = service, config.service_port(service)
78     except Exception:
79         pass
80 
81     # Fallback rules and route customizations applied below
82 
83     if host.endswith('cloudfront.net'):
84         path = path or '/'
85         result = 'cloudfront', config.PORT_CLOUDFRONT
86     elif target.startswith('AWSCognitoIdentityProviderService') or 'cognito-idp.' in host:
87         result = 'cognito-idp', config.PORT_COGNITO_IDP
88     elif target.startswith('AWSCognitoIdentityService') or 'cognito-identity.' in host:
89         result = 'cognito-identity', config.PORT_COGNITO_IDENTITY
90     elif result[0] == 's3' or re.match(r'.*s3(\-website)?\.([^\.]+\.)?amazonaws.com', host):
91         host = re.sub(r's3-website\..*\.amazonaws', 's3.amazonaws', host)
92         result = 's3', config.PORT_S3
93     elif result[0] == 'states' in auth_header or host.startswith('states.'):
94         result = 'stepfunctions', config.PORT_STEPFUNCTIONS
95     elif '.execute-api.' in host:
96         result = 'apigateway', config.PORT_APIGATEWAY
97     elif target.startswith('DynamoDBStreams') or host.startswith('streams.dynamodb.'):
98         result = 'dynamodbstreams', config.PORT_DYNAMODBSTREAMS
99     elif ls_target == 'web' or path == '/graph':
100         result = 'web', config.PORT_WEB_UI
101 
102     return result[0], result[1], path, host
103 
104 
105 def do_start_edge(port, use_ssl, asynchronous=False):
106     try:
107         # start local DNS server, if present
108         from localstack_ext.services import dns_server
109         dns_server.start_servers()
110     except Exception:
111         pass
112 
113     # get port and start Edge
114     print('Starting edge router (http%s port %s)...' % ('s' if use_ssl else '', port))
115     # use use=True here because our proxy allows both, HTTP and HTTPS traffic
116     proxy = GenericProxy(port, ssl=True, update_listener=ProxyListenerEdge())
117     proxy.start()
118     if not asynchronous:
119         proxy.join()
120     return proxy
121 
122 
123 def can_use_sudo():
124     try:
125         run('echo | sudo -S echo', print_error=False)
126         return True
127     except Exception:
128         return False
129 
130 
131 def ensure_can_use_sudo():
132     if not is_root() and not can_use_sudo():
133         print('Please enter your sudo password (required to configure local network):')
134         run('sudo echo', stdin=True)
135 
136 
137 def start_edge(port=None, use_ssl=True, asynchronous=False):
138     if not port:
139         port = config.EDGE_PORT
140     if config.EDGE_PORT_HTTP:
141         do_start_edge(config.EDGE_PORT_HTTP, use_ssl=False, asynchronous=True)
142     if port > 1024 or is_root():
143         return do_start_edge(port, use_ssl, asynchronous=asynchronous)
144 
145     # process requires priviledged port but we're not root -> try running as sudo
146 
147     class Terminator(object):
148 
149         def stop(self, quiet=True):
150             try:
151                 url = 'http%s://localhost:%s' % ('s' if use_ssl else '', port)
152                 requests.verify_ssl = False
153                 requests.post(url, headers={HEADER_KILL_SIGNAL: 'kill'})
154             except Exception:
155                 pass
156 
157     # make sure we can run sudo commands
158     ensure_can_use_sudo()
159 
160     # register a signal handler to terminate the sudo process later on
161     TMP_THREADS.append(Terminator())
162 
163     # start the process as sudo
164     sudo_cmd = 'sudo '
165     python_cmd = sys.executable
166     cmd = '%sPYTHONPATH=.:%s %s %s %s' % (sudo_cmd, LOCALSTACK_ROOT_FOLDER, python_cmd, __file__, port)
167     process = run(cmd, asynchronous=asynchronous)
168     return process
169 
170 
171 if __name__ == '__main__':
172     logging.basicConfig()
173     start_edge(int(sys.argv[1]))
174
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/localstack/services/edge.py b/localstack/services/edge.py
--- a/localstack/services/edge.py
+++ b/localstack/services/edge.py
@@ -38,6 +38,10 @@
             # detect S3 presigned URLs
             if 'AWSAccessKeyId=' in path or 'Signature=' in path:
                 port = config.PORT_S3
+            # assume that this is an S3 GET request with URL path `/<bucket>/<key ...>`
+            # TODO: move S3 public URLs to a separate port/endpoint, OR check ACLs here first
+            if method == 'GET' and '/' in path.strip('/'):
+                port = config.PORT_S3
 
         if not port:
             LOG.info('Unable to find forwarding rule for host "%s", path "%s", target header "%s", auth header "%s"' %

{"golden_diff": "diff --git a/localstack/services/edge.py b/localstack/services/edge.py\n--- a/localstack/services/edge.py\n+++ b/localstack/services/edge.py\n@@ -38,6 +38,10 @@\n             # detect S3 presigned URLs\n             if 'AWSAccessKeyId=' in path or 'Signature=' in path:\n                 port = config.PORT_S3\n+            # assume that this is an S3 GET request with URL path `/<bucket>/<key ...>`\n+            # TODO: move S3 public URLs to a separate port/endpoint, OR check ACLs here first\n+            if method == 'GET' and '/' in path.strip('/'):\n+                port = config.PORT_S3\n \n         if not port:\n             LOG.info('Unable to find forwarding rule for host \"%s\", path \"%s\", target header \"%s\", auth header \"%s\"' %\n", "issue": "s3.upload returns `Location: http://localhost:4566`\n# Bug report\r\n\r\n# Detailed description\r\n\r\nThe `AWS.s3.upload()` (official SDK - https://github.com/aws/aws-sdk-js) returns an object with the `Location` key that points to 4566 instead of 4572 (LocalStack S3 port).\r\n\r\n## Expected behavior\r\n\r\nThe `Location` should point to the file on S3.\r\n\r\nExample:\r\n\r\n```\r\nLocation: http://localhost:4572/path/to/bucket.txt\r\n```\r\n\r\n## Actual behavior\r\n\r\nThe `Location` points to the LocalStack entrypoint.\r\n\r\nExample:\r\n\r\n```\r\nLocation: http://localhost:4566/path/to/bucket.txt\r\n```\r\n\r\n# Steps to reproduce\r\n\r\n- Upload a file to S3 using the official AWS SDK (https://github.com/aws/aws-sdk-js).\r\n- Check out the `Location` property.\r\n\r\n## Client code\r\n\r\n```javascript\r\nconst AWS = require('aws-sdk');\r\nconst s3 = new AWS.S3({\r\n  region: 'us-west-1',\r\n  endpoint: 'http://localhost:4566',\r\n  apiVersion: '2006-03-01',\r\n  s3ForcePathStyle: true,\r\n});\r\n\r\n(async () => {\r\n  await s3\r\n    .createBucket({ Bucket: 'my-bucket', ACL: 'private' })\r\n    .promise();\r\n\r\n  const { Location } = await s3\r\n    .upload({ Key: 'file.txt', Body: 'test', Bucket: 'my-bucket' })\r\n    .promise();\r\n\r\n  console.assert(Location === 'http://localhost:4572/my-bucket/file.txt');\r\n})();\r\n```\n", "before_files": [{"content": "import re\nimport os\nimport sys\nimport json\nimport logging\nfrom requests.models import Response\nfrom localstack import config\nfrom localstack.constants import HEADER_LOCALSTACK_TARGET, HEADER_LOCALSTACK_EDGE_URL, LOCALSTACK_ROOT_FOLDER\nfrom localstack.utils.common import run, is_root, TMP_THREADS\nfrom localstack.utils.common import safe_requests as requests\nfrom localstack.services.generic_proxy import ProxyListener, GenericProxy\n\nLOG = logging.getLogger(__name__)\n\n# Header to indicate that the process should kill itself. This is required because if\n# this process is started as root, then we cannot kill it from a non-root process\nHEADER_KILL_SIGNAL = 'x-localstack-kill'\n\n\nclass ProxyListenerEdge(ProxyListener):\n\n    def forward_request(self, method, path, data, headers):\n        if method == 'OPTIONS':\n            return 200\n\n        # kill the process if we receive this header\n        headers.get(HEADER_KILL_SIGNAL) and os._exit(0)\n\n        target = headers.get('x-amz-target', '')\n        auth_header = headers.get('authorization', '')\n        host = headers.get('host', '')\n        headers[HEADER_LOCALSTACK_EDGE_URL] = 'https://%s' % host\n\n        # extract API details\n        _, port, path, host = get_api_from_headers(headers, path)\n\n        if not port:\n            # detect S3 presigned URLs\n            if 'AWSAccessKeyId=' in path or 'Signature=' in path:\n                port = config.PORT_S3\n\n        if not port:\n            LOG.info('Unable to find forwarding rule for host \"%s\", path \"%s\", target header \"%s\", auth header \"%s\"' %\n                     (host, path, target, auth_header))\n            response = Response()\n            response.status_code = 404\n            response._content = '{\"status\": \"running\"}'\n            return response\n\n        use_ssl = config.USE_SSL\n\n        connect_host = '%s:%s' % (config.HOSTNAME, port)\n        url = 'http%s://%s%s' % ('s' if use_ssl else '', connect_host, path)\n        headers['Host'] = host\n        function = getattr(requests, method.lower())\n        if isinstance(data, dict):\n            data = json.dumps(data)\n\n        response = function(url, data=data, headers=headers, verify=False)\n        return response\n\n\ndef get_api_from_headers(headers, path=None):\n    target = headers.get('x-amz-target', '')\n    host = headers.get('host', '')\n    auth_header = headers.get('authorization', '')\n    ls_target = headers.get(HEADER_LOCALSTACK_TARGET, '')\n    path = path or '/'\n\n    # initialize result\n    result = '_unknown_', 0\n\n    # https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html\n    try:\n        credential_scope = auth_header.split(',')[0].split()[1]\n        _, _, _, service, _ = credential_scope.split('/')\n        result = service, config.service_port(service)\n    except Exception:\n        pass\n\n    # Fallback rules and route customizations applied below\n\n    if host.endswith('cloudfront.net'):\n        path = path or '/'\n        result = 'cloudfront', config.PORT_CLOUDFRONT\n    elif target.startswith('AWSCognitoIdentityProviderService') or 'cognito-idp.' in host:\n        result = 'cognito-idp', config.PORT_COGNITO_IDP\n    elif target.startswith('AWSCognitoIdentityService') or 'cognito-identity.' in host:\n        result = 'cognito-identity', config.PORT_COGNITO_IDENTITY\n    elif result[0] == 's3' or re.match(r'.*s3(\\-website)?\\.([^\\.]+\\.)?amazonaws.com', host):\n        host = re.sub(r's3-website\\..*\\.amazonaws', 's3.amazonaws', host)\n        result = 's3', config.PORT_S3\n    elif result[0] == 'states' in auth_header or host.startswith('states.'):\n        result = 'stepfunctions', config.PORT_STEPFUNCTIONS\n    elif '.execute-api.' in host:\n        result = 'apigateway', config.PORT_APIGATEWAY\n    elif target.startswith('DynamoDBStreams') or host.startswith('streams.dynamodb.'):\n        result = 'dynamodbstreams', config.PORT_DYNAMODBSTREAMS\n    elif ls_target == 'web' or path == '/graph':\n        result = 'web', config.PORT_WEB_UI\n\n    return result[0], result[1], path, host\n\n\ndef do_start_edge(port, use_ssl, asynchronous=False):\n    try:\n        # start local DNS server, if present\n        from localstack_ext.services import dns_server\n        dns_server.start_servers()\n    except Exception:\n        pass\n\n    # get port and start Edge\n    print('Starting edge router (http%s port %s)...' % ('s' if use_ssl else '', port))\n    # use use=True here because our proxy allows both, HTTP and HTTPS traffic\n    proxy = GenericProxy(port, ssl=True, update_listener=ProxyListenerEdge())\n    proxy.start()\n    if not asynchronous:\n        proxy.join()\n    return proxy\n\n\ndef can_use_sudo():\n    try:\n        run('echo | sudo -S echo', print_error=False)\n        return True\n    except Exception:\n        return False\n\n\ndef ensure_can_use_sudo():\n    if not is_root() and not can_use_sudo():\n        print('Please enter your sudo password (required to configure local network):')\n        run('sudo echo', stdin=True)\n\n\ndef start_edge(port=None, use_ssl=True, asynchronous=False):\n    if not port:\n        port = config.EDGE_PORT\n    if config.EDGE_PORT_HTTP:\n        do_start_edge(config.EDGE_PORT_HTTP, use_ssl=False, asynchronous=True)\n    if port > 1024 or is_root():\n        return do_start_edge(port, use_ssl, asynchronous=asynchronous)\n\n    # process requires priviledged port but we're not root -> try running as sudo\n\n    class Terminator(object):\n\n        def stop(self, quiet=True):\n            try:\n                url = 'http%s://localhost:%s' % ('s' if use_ssl else '', port)\n                requests.verify_ssl = False\n                requests.post(url, headers={HEADER_KILL_SIGNAL: 'kill'})\n            except Exception:\n                pass\n\n    # make sure we can run sudo commands\n    ensure_can_use_sudo()\n\n    # register a signal handler to terminate the sudo process later on\n    TMP_THREADS.append(Terminator())\n\n    # start the process as sudo\n    sudo_cmd = 'sudo '\n    python_cmd = sys.executable\n    cmd = '%sPYTHONPATH=.:%s %s %s %s' % (sudo_cmd, LOCALSTACK_ROOT_FOLDER, python_cmd, __file__, port)\n    process = run(cmd, asynchronous=asynchronous)\n    return process\n\n\nif __name__ == '__main__':\n    logging.basicConfig()\n    start_edge(int(sys.argv[1]))\n", "path": "localstack/services/edge.py"}], "after_files": [{"content": "import re\nimport os\nimport sys\nimport json\nimport logging\nfrom requests.models import Response\nfrom localstack import config\nfrom localstack.constants import HEADER_LOCALSTACK_TARGET, HEADER_LOCALSTACK_EDGE_URL, LOCALSTACK_ROOT_FOLDER\nfrom localstack.utils.common import run, is_root, TMP_THREADS\nfrom localstack.utils.common import safe_requests as requests\nfrom localstack.services.generic_proxy import ProxyListener, GenericProxy\n\nLOG = logging.getLogger(__name__)\n\n# Header to indicate that the process should kill itself. This is required because if\n# this process is started as root, then we cannot kill it from a non-root process\nHEADER_KILL_SIGNAL = 'x-localstack-kill'\n\n\nclass ProxyListenerEdge(ProxyListener):\n\n    def forward_request(self, method, path, data, headers):\n        if method == 'OPTIONS':\n            return 200\n\n        # kill the process if we receive this header\n        headers.get(HEADER_KILL_SIGNAL) and os._exit(0)\n\n        target = headers.get('x-amz-target', '')\n        auth_header = headers.get('authorization', '')\n        host = headers.get('host', '')\n        headers[HEADER_LOCALSTACK_EDGE_URL] = 'https://%s' % host\n\n        # extract API details\n        _, port, path, host = get_api_from_headers(headers, path)\n\n        if not port:\n            # detect S3 presigned URLs\n            if 'AWSAccessKeyId=' in path or 'Signature=' in path:\n                port = config.PORT_S3\n            # assume that this is an S3 GET request with URL path `/<bucket>/<key ...>`\n            # TODO: move S3 public URLs to a separate port/endpoint, OR check ACLs here first\n            if method == 'GET' and '/' in path.strip('/'):\n                port = config.PORT_S3\n\n        if not port:\n            LOG.info('Unable to find forwarding rule for host \"%s\", path \"%s\", target header \"%s\", auth header \"%s\"' %\n                     (host, path, target, auth_header))\n            response = Response()\n            response.status_code = 404\n            response._content = '{\"status\": \"running\"}'\n            return response\n\n        use_ssl = config.USE_SSL\n\n        connect_host = '%s:%s' % (config.HOSTNAME, port)\n        url = 'http%s://%s%s' % ('s' if use_ssl else '', connect_host, path)\n        headers['Host'] = host\n        function = getattr(requests, method.lower())\n        if isinstance(data, dict):\n            data = json.dumps(data)\n\n        response = function(url, data=data, headers=headers, verify=False)\n        return response\n\n\ndef get_api_from_headers(headers, path=None):\n    target = headers.get('x-amz-target', '')\n    host = headers.get('host', '')\n    auth_header = headers.get('authorization', '')\n    ls_target = headers.get(HEADER_LOCALSTACK_TARGET, '')\n    path = path or '/'\n\n    # initialize result\n    result = '_unknown_', 0\n\n    # https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html\n    try:\n        credential_scope = auth_header.split(',')[0].split()[1]\n        _, _, _, service, _ = credential_scope.split('/')\n        result = service, config.service_port(service)\n    except Exception:\n        pass\n\n    # Fallback rules and route customizations applied below\n\n    if host.endswith('cloudfront.net'):\n        path = path or '/'\n        result = 'cloudfront', config.PORT_CLOUDFRONT\n    elif target.startswith('AWSCognitoIdentityProviderService') or 'cognito-idp.' in host:\n        result = 'cognito-idp', config.PORT_COGNITO_IDP\n    elif target.startswith('AWSCognitoIdentityService') or 'cognito-identity.' in host:\n        result = 'cognito-identity', config.PORT_COGNITO_IDENTITY\n    elif result[0] == 's3' or re.match(r'.*s3(\\-website)?\\.([^\\.]+\\.)?amazonaws.com', host):\n        host = re.sub(r's3-website\\..*\\.amazonaws', 's3.amazonaws', host)\n        result = 's3', config.PORT_S3\n    elif result[0] == 'states' in auth_header or host.startswith('states.'):\n        result = 'stepfunctions', config.PORT_STEPFUNCTIONS\n    elif '.execute-api.' in host:\n        result = 'apigateway', config.PORT_APIGATEWAY\n    elif target.startswith('DynamoDBStreams') or host.startswith('streams.dynamodb.'):\n        result = 'dynamodbstreams', config.PORT_DYNAMODBSTREAMS\n    elif ls_target == 'web' or path == '/graph':\n        result = 'web', config.PORT_WEB_UI\n\n    return result[0], result[1], path, host\n\n\ndef do_start_edge(port, use_ssl, asynchronous=False):\n    try:\n        # start local DNS server, if present\n        from localstack_ext.services import dns_server\n        dns_server.start_servers()\n    except Exception:\n        pass\n\n    # get port and start Edge\n    print('Starting edge router (http%s port %s)...' % ('s' if use_ssl else '', port))\n    # use use=True here because our proxy allows both, HTTP and HTTPS traffic\n    proxy = GenericProxy(port, ssl=True, update_listener=ProxyListenerEdge())\n    proxy.start()\n    if not asynchronous:\n        proxy.join()\n    return proxy\n\n\ndef can_use_sudo():\n    try:\n        run('echo | sudo -S echo', print_error=False)\n        return True\n    except Exception:\n        return False\n\n\ndef ensure_can_use_sudo():\n    if not is_root() and not can_use_sudo():\n        print('Please enter your sudo password (required to configure local network):')\n        run('sudo echo', stdin=True)\n\n\ndef start_edge(port=None, use_ssl=True, asynchronous=False):\n    if not port:\n        port = config.EDGE_PORT\n    if config.EDGE_PORT_HTTP:\n        do_start_edge(config.EDGE_PORT_HTTP, use_ssl=False, asynchronous=True)\n    if port > 1024 or is_root():\n        return do_start_edge(port, use_ssl, asynchronous=asynchronous)\n\n    # process requires priviledged port but we're not root -> try running as sudo\n\n    class Terminator(object):\n\n        def stop(self, quiet=True):\n            try:\n                url = 'http%s://localhost:%s' % ('s' if use_ssl else '', port)\n                requests.verify_ssl = False\n                requests.post(url, headers={HEADER_KILL_SIGNAL: 'kill'})\n            except Exception:\n                pass\n\n    # make sure we can run sudo commands\n    ensure_can_use_sudo()\n\n    # register a signal handler to terminate the sudo process later on\n    TMP_THREADS.append(Terminator())\n\n    # start the process as sudo\n    sudo_cmd = 'sudo '\n    python_cmd = sys.executable\n    cmd = '%sPYTHONPATH=.:%s %s %s %s' % (sudo_cmd, LOCALSTACK_ROOT_FOLDER, python_cmd, __file__, port)\n    process = run(cmd, asynchronous=asynchronous)\n    return process\n\n\nif __name__ == '__main__':\n    logging.basicConfig()\n    start_edge(int(sys.argv[1]))\n", "path": "localstack/services/edge.py"}]}