Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added configurable port & bind addresses #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions wine-dispatch/wine-dispatch
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/python3.6

import os

import sys
import struct

Expand All @@ -18,20 +20,22 @@ class ExecutionHandler(socketserver.BaseRequestHandler):

def handle(self):
arguments = list(self.read_string() for _ in range(self.read_int()))

print("CMD", *arguments)
print("---------")

process = subprocess.run(arguments,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

self.request.sendall(b"e" + struct.pack("B", process.returncode))
self.request.close()

if __name__ == "__main__":
HOST, PORT = "127.0.0.1", 8889
HOST = os.environ.get("HOST", "127.0.0.1")
PORT = int(os.environ.get("PORT", "8888"))
print(f"Starting server on {HOST}:{PORT}")

# Create the server, binding to localhost on port 9999
with socketserver.ThreadingTCPServer((HOST, PORT), ExecutionHandler) as server:
Expand Down