So I have some API server that I need to be up 24/7. Is it a bad idea to open up a tmux window and run the server application? When you run a binary in tmux, the binary stays running even when you close the tmux window. The binary also stays running when I disconnect from the SSH session. I like running the server application in tmux because I can easily just attach to the tmux window and have access to a shell where the executable lives. The server constantly prints log messages to standard output, meaning I like to be able to read those messages in my tmux window. However, there is something that just seems off about this method of running a server application. I would prefer if the server could somehow run in the background, but I also want to be able to see the logs that the terminal is printing out at any given time. So, to summarize, is it a bad idea to run a server application in tmux? If so, what do I do instead so that I can still read the server application's logs?
What you want can be done. I've seen it done with GNU screen when Tmux wasn't around yet. However, I would not consider it good style to do it.
There are better ways to do this. Daemons are simply "normal" processes being run in a particular way. That particular way usually means to fork "twice" (so that the parent/child relationship gets broken) and plugging stdout, stdin and stderr to some file (or
/dev/null if no logging is desired).
There are tools aplenty out there to achieve what you want while also ensuring that there is a policy in place if the process unexpectedly goes down. After all a service should be available as close to 100% of the time as possible.
Read up on:
Arguably your system will already have one of these or a very similar tool installed. But you don't give enough information for me to provide more detail.