Skip to content

Commit 69080f2

Browse files
authored
Merge pull request #9 from lsst-dm/IT-5635/s3daemon-port
add S3DAEMON_HOST & S3DAEMON_PORT env vars
2 parents 0f0e90a + 0ba633b commit 69080f2

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

python/s3daemon/s3daemon.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
),
3737
)
3838

39-
PORT = 15555
39+
host = os.environ.get("S3DAEMON_HOST", "localhost")
40+
port = int(os.environ.get("S3DAEMON_PORT", 15555))
4041
endpoint_url = os.environ["S3_ENDPOINT_URL"]
4142
access_key = os.environ["AWS_ACCESS_KEY_ID"]
4243
secret_key = os.environ["AWS_SECRET_ACCESS_KEY"]
@@ -89,7 +90,7 @@ async def main():
8990
async def client_cb(reader, writer):
9091
await handle_client(client, reader, writer)
9192

92-
server = await asyncio.start_server(client_cb, "localhost", PORT)
93+
server = await asyncio.start_server(client_cb, host, port)
9394
log.info("Starting server")
9495
async with server:
9596
await server.serve_forever()

python/s3daemon/send.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
# You should have received a copy of the GNU General Public License
2020
# along with this program. If not, see <https://www.gnu.org/licenses/>.
2121

22+
import os
2223
import socket
2324
import sys
2425

25-
PORT = 15555
26+
host = os.environ.get("S3DAEMON_HOST", "localhost")
27+
port = int(os.environ.get("S3DAEMON_PORT", 15555))
2628

2729

2830
def send(filename, dest):
@@ -37,7 +39,7 @@ def send(filename, dest):
3739
The key may contain slashes.
3840
"""
3941
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
40-
sock.connect(("localhost", PORT))
42+
sock.connect((host, port))
4143
sock.sendall(bytes(f"{filename} {dest}\n", "UTF-8"))
4244
received = str(sock.recv(4096), "utf-8")
4345
sock.close()

0 commit comments

Comments
 (0)