From 1bb629c18f8650a2986cde304547ed455e4b2cb1 Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Sun, 23 Apr 2023 03:56:55 -0700 Subject: [PATCH] Add command-line options for bind host and port. --- Sources/StableDiffusionServer/main.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sources/StableDiffusionServer/main.swift b/Sources/StableDiffusionServer/main.swift index f82803c..da70322 100644 --- a/Sources/StableDiffusionServer/main.swift +++ b/Sources/StableDiffusionServer/main.swift @@ -9,6 +9,12 @@ struct ServerCommand: ParsableCommand { @Option(name: .shortAndLong, help: "Path to models directory") var modelsDirectoryPath: String = "models" + @Option(name: .long, help: "Bind host") + var bindHost: String = "0.0.0.0" + + @Option(name: .long, help: "Bind port") + var bindPort: Int = 4546 + mutating func run() throws { let modelsDirectoryURL = URL(filePath: modelsDirectoryPath) let modelManager = ModelManager(modelBaseURL: modelsDirectoryURL) @@ -30,7 +36,7 @@ struct ServerCommand: ParsableCommand { ModelServiceProvider(modelManager: modelManager), ImageGenerationServiceProvider(modelManager: modelManager) ]) - .bind(host: "0.0.0.0", port: 4546) + .bind(host: bindHost, port: bindPort) dispatchMain() }