Embedded server stops after SSH logout

If I SSH into a server, and

box server start server_by_name

It stops when I log out.

So obviously, this isn’t an intended method for running a staging or production instance. What should I be doing to keep the server running, or should I not be using CommandBox in staging and production (opting for a full Lucee install instead)?

If this question has already been answered, I was unable to find it. Apologies if so, and I’d be grateful for a quick link in that case.

Sounds like a bug where the server process ID is getting tied to the console process for your user and the OS must be killing off the child process. I’m using CommandBox in “production” right now on my Raspberry Pi server and I just have an init.d script that starts the server on boot so I’ve never noticed that. I’ll have to have Denny take a look at how the processes are spawned. It’s certainly not the intended behavior that the server would quit when you log out. Can you get some information on the process that the servers runs under and see if it’s somehow tied to your SSH session?

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

I pinged Denny on this. Here’s a couple links that might apply, though these two are Linux specific:

https://stackoverflow.com/questions/24154189/how-to-run-a-shell-script-from-java-and-have-it-continue-running-after-jvm-shutd

https://unix.stackexchange.com/questions/125072/process-java-still-being-killed

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Thanks for those links - I’m vaguely familiar with the process of leaving a job running after the user disconnects. However, I’d prefer not to have to write a script or some strange alias for this (sort of defeats the convenience of CommandBox, as I’m sure you’ll agree).

I am on Linux, using SSH and tmux, often via MobaXterm on Windows or aterm or xfce-terminal.

After some experimentation, it looks like this only occurs on MobaXterm - it must be killing the parent process on closing the window. If I logout or exit, the server stays running until I close the actual window in which the terminal is running. I’m guessing by the pause when I do so that MobaXterm is sending HUPs to the user process which is the parent of the server process.

On Linux, I can close the local terminal and it just disconnects without sending any HUP. I can even kill the tmux session the server was started in and it keeps running. I can log in, start the server and exit or logout and the server stays running. This is perfectly fine.

So in short, this looks like an issue with MobaXterm. There’s gotta be a setting that disabled HUPs on window close. Sorry to waste your time, and thank you kindly for the kick in the pants to find the real cause.

I have to say that for such a small team of folks who are as busy as we all are, you’re doing great work here and consistently going above and beyond. It’s much appreciated and stands out above any other framework or utility development group I’ve ever come across.

Thanks for the kind words Sean :slight_smile: And to be clear, I wasn’t implying that you were doing anything wrong or needed to change your approach. The links I pasted in were more notes for Denny and I to look into how we could kick off the server process differently inside of CommandBox to help prevent your issue. Nice working narrowing it down to the terminal you were using. I’m def curious if this is still something we can handle a little differently so it doesn’t trip people up in the future.

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

I agree - it would be nice if the script “disowned” the process or something similar. That way the server isn’t tied to a permanent login. If I’m just tossing out ideas, it would be way cool if there was a way to have an Apache module or something that would start a server if it wasn’t running. Of course, I have no idea if that’s even possible with all the flexible power CommandBox provides.

Or it would also be handy if the server start command could check in the respective .conf for the Proxy commands, and either inject them, or at least give you a handy echo to copy/paste. It would help make sure the port was all correct and whatnot. I’m considering writing a shell script that does that, and it should be fairly trivial, but if you need another feature for the pile…

I’ll tell you that CommandBox has already changed my approach in the best ways, so I’m always looking to have my anti-patterns jostled. It’s incredibly freeing to not be chained to Adobe software that hasn’t been “modern” for a decade. This from a guy who uses (neo)vim as his IDE, so.