I created a fairly straight-forward node application with socket.io, but when I put it into production, I couldn’t get it to work. It was dead on arrival. After looking up a ton of examples I figured out what the problem was. (I apologize in advance if this is obvious to seasoned node developers.) Assuming everything else is running…
When a node application crashes unexpectedly, you might get a
EADDRINUSE, Address already in use error when you try to restart it. This means that the port you’re using is already being used by the crashed application. What you need to do is fun the PID of that process, and then kill it. There’s more than one way to skin that cat, but I like to use
netstat. N.B. You’ll need to run this as
sudo for it to work.
I found this great tutorial on
tmux by Daniel Miessler that was designed to take you from “wtf tmux” to “omg tmux” with extreme haste. I’m reproducing parts of that blog post here because I find myself googling it at least three times a day. (Because it’s that useful.) Briefly,
tmux is a utility that allows you to connect to a remote server, start a job, and then log off without quitting your job. When you log back in from another location, you can access that job again through
screen utility also does this, but not as well. For instance, if you have a really long username, then you might not be able to start screen, because edge cases.