Commit graph

19 commits

Author SHA1 Message Date
Claude
51d75cfe6e
fix: search accumulated log buffer for server readiness line
The stdout reader matched 'EngineFS server started at' against
string_data (the bytes from the most recent read only). If server.js
flushed in such a way that the readiness line straddled two reads,
neither chunk's .lines() yielded a full match, the endpoint channel
never received, recv() timed out, and the WebUI loaded against the
fallback URL.

Search the accumulated *lines buffer instead so a line split across
reads matches once the second chunk lands. Track endpoint_sent so we
do not resend on every subsequent chunk after a match.

Also preserve trailing newlines when trimming the retained buffer to
SRV_LOG_SIZE lines so a later chunk cannot be concatenated onto the
last unterminated line and corrupt a parser. Same trim treatment for
the stderr reader for consistency.

Closes #53
2026-05-10 14:43:48 +00:00
Claude
1464d46172
fix: kill and wait stremio-runtime child after readers finish
After both stdout and stderr readers exited, the Child handle was just
dropped at the end of the match arm. On Windows std::process::Child's
Drop neither kills nor waits, so the OS process kept its kernel object
(and its bound ports) alive until either the JobObject KILL_ON_JOB_CLOSE
fired on shell exit or init adopted it.

In the crash-restart path this is worse: a fresh start() is launched
while the previous runtime is still being reaped, and both processes
race for port 11470.

Explicitly kill().ok() + wait().ok() once the readers see EOF so the
previous runtime is gone before we report 'Server terminated.' and fire
the crash notice. Errors from killing an already-exited child are
intentionally swallowed.

Closes #50
2026-05-10 14:43:28 +00:00
Claude
2294f52407
fix: guard JobObject setup with Once and check return values
CreateJobObjectA / SetInformationJobObject / AssignProcessToJobObject
were called inside the per-start thread and their return values were
ignored. Two consequences:

1. Each server crash-restart created a fresh kernel JobObject HANDLE
   that was never CloseHandle'd. The HANDLE went out of scope when the
   spawned thread exited, leaking a kernel object every crash.
2. On Win 7/8 (single-job systems) and inside parent jobs that disallow
   breakaway, AssignProcessToJobObject silently failed, so
   stremio-runtime could survive the shell's death and hold port 11470.

Hoist the setup into ensure_parent_job_object() guarded by sync::Once
so it runs exactly once per shell process, and check each return value
explicitly with a clear log message when the OS-level safety net is
degraded. The HANDLE is intentionally not closed: closing it while
KILL_ON_JOB_CLOSE is set would terminate the shell itself.

Closes #47
Closes #48
2026-05-10 14:43:06 +00:00
Claude
a9d9673f2a
fix: break server reader threads on read error
stdout.read(...).unwrap_or(!0) substituted usize::MAX on Err, then
`if on > buffer.len() { continue; }` swallowed it and looped back into
read(). On a sticky IO error (broken pipe, EBADF) the thread spun a
CPU core forever and the accumulated logs were never flushed.

Match Ok(0)/Ok(n)/Err(e) explicitly: break on EOF, break on error after
logging, and treat any other Ok(n) as bytes read. Same change for
stderr.

Closes #51
2026-05-10 12:32:20 +00:00
Vladimir Borisov
b37fbbd4c8
64 bit build 2025-06-30 12:39:12 +03:00
Vladimir Borisov
03921ffce9
Clippy 2025-01-21 11:53:38 +02:00
Vladimir Borisov
8e1b72d513
Server crash logs and boot availability 2025-01-21 11:45:14 +02:00
Vladimir Borisov
4622458f6f Use constant from winapi crate 2024-04-22 15:12:32 +03:00
Vladimir Borisov
b8c68029ed Execute the server from the same directory the main executable is 2024-04-22 12:53:53 +03:00
Vladimir Borisov
e88653974b Fix autoupdater 2024-04-19 18:44:33 +03:00
Vladimir Borisov
c8fbba0a62 Updated dependencies. Fixed errors 2024-03-07 17:38:43 +02:00
Vladimir Borisov
eeab2bb072 Remove unused import 2022-09-30 15:55:51 +03:00
Vladimir Borisov
b85cf31cd1 Slightly better error handling for the server 2022-09-30 15:51:59 +03:00
Vladimir Borisov
7827832670 Update server.js to 4.4.159 2022-09-29 18:19:23 +03:00
Vladimir Borisov
7a7494f726 Use Windows line endings for easier diff 2022-04-08 09:16:46 +03:00
Martin Kavík
f10380f60a minor refactor + cargo fmt --all 2022-04-01 22:47:02 +02:00
Vladimir Borisov
76ff6cac5b Better way to hide the terminal 2021-11-17 11:24:25 +02:00
Vladimir Borisov
12a44b0ff6 Run server as win32 job 2021-08-02 16:10:11 +03:00
Vladimir Borisov
e6cb1d8fa6 Renamed files. Clippy is happy 2021-07-26 14:07:04 +03:00
Renamed from src/stremio_app/stremio_server/stremio_server.rs (Browse further)