I made a small HTTP server using jlink that works when running with the frontend. Now I need to keep a stand-alone math kernel alive after all functions have evaluated for the server to stay up. All functions (including the function to start the server) return immediately, so the behavior of math -script server.m is to exit immediately.
Adding While[True, Pause[1]] to the end of the file causes the server to become unresponsive. $IgnoreEOF=True has no effect (as the documentation says). I experimented briefly with shell tricks (piping to stdin), but did not find a solution -- I'm not a shell expert, and this is on Windows, so solutions are limited to those compatible with PowerShell and SUA.
Similar question to Keep kernel running for execution of scheduled task, but those answers (at least, the While[True...] thing) haven't worked.