Skip to content

armgit / kokon

Public Imported from GitHub
0

Edit photos by describing the change, on your own GPU. A free, open-source alternative to Nano Banana and ChatGPT image editing: photos stay on your computer, no daily limit. One installer for Windows, Mac and Linux sets up the best open model (Qwen-Image 2.1). MCP server for AI agents.

fix(qls-core): point port-in-use suggestion at serverPort in config.json (#12)

Pedro Monteirobfcfaa3a4da6
diff --git a/crates/qls-core/src/error.rs b/crates/qls-core/src/error.rs
index 3328766..eb21b71 100644
--- a/crates/qls-core/src/error.rs
+++ b/crates/qls-core/src/error.rs
@@ -4,6 +4,8 @@
use serde::{Deserialize, Serialize};
use std::fmt;
+use crate::config::AppConfig;
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ErrorCode {
@@ -156,7 +158,7 @@ pub fn translate_startup_failure(log_tail: &str) -> AppError {
}
if lc.contains("address already in use") || lc.contains("bind") && lc.contains("fail") {
return AppError::new(ErrorCode::ServerStartFailed, "The inference server port is already in use.")
- .suggest("Choose another port in Settings.")
+ .suggest(&format!("Close the program using the port, or change \"serverPort\" in {}.", AppConfig::path().display()))
.detail(log_tail.to_string());
}
if lc.contains("cuda") && (lc.contains("no cuda") || lc.contains("cuda error") || lc.contains("no devices")) {
@@ -201,6 +203,15 @@ mod tests {
assert_eq!(translate_startup_failure("weird").code, ErrorCode::ServerStartFailed);
}
+ #[test]
+ fn port_in_use_points_at_the_config_file() {
+ let e = translate_startup_failure("bind() to 127.0.0.1:39150 failed: address already in use");
+ assert_eq!(e.code, ErrorCode::ServerStartFailed);
+ let s = e.suggestion.unwrap();
+ assert!(s.contains("serverPort"), "{}", s);
+ assert!(s.contains("config.json"), "{}", s);
+ }
+
#[test]
fn statuses() {
assert_eq!(AppError::invalid("x").http_status(), 400);
diff --git a/docs/engineering-notes.md b/docs/engineering-notes.md
index 0774015..afa11eb 100644
--- a/docs/engineering-notes.md
+++ b/docs/engineering-notes.md
@@ -231,7 +231,7 @@ In `%APPDATA%\Kokon\config.json`: `hardwarePreset` (`12gb|16gb|24gb|32gb`, writt
setup screen), `vramOverrideMib` (plan sizes as if the GPU had this much VRAM; 0 = detect;
for testing), `upscaleTileSize` (0 = automatic, see the upscaler section; schema 8 reset it),
`ui.engineUpdateSkipped` (engine release whose update was skipped in Setup),
-`prefixCacheType`, `eagerLoad`, `sageAttention`.
+`prefixCacheType`, `eagerLoad`, `sageAttention`, `serverPort` (39150 = default).
## Testing smaller cards on a bigger one