Manage processes with nproc
So, after 30 years of “heavier” languages such as C++, Java, C#, I’m really liking Node.js as a change. Being able to prototype things quickly, having the server start up in sub-second times, and not being encased in a few hundred megabytes of virtual machine is pretty neat. I think the ecosystem has a lot of maturing to do before it moves from a “latest thing” to a true force to be reckoned with, but I think it will get there.
I’m presently developing on a 15" Windows 8 laptop. Definitely not the system of choice, but it gets the job done (and it’s light enough that my daughter can move it without dropping it). One of the things that it lacks is screen real estate. Alt-tabbing between windows can break that creative stride when you’re dealing with Mongo running in one console, an API server running in another, nodemon running your current codebase in a another, in addition to the other more interactive consoles. I mean, a lot of these aren’t windows that you really interact with, but you still have to alt-tab through them. It’s handy to be able to see mongod running and what it’s thinking about, but it’s not like I actually interact with it.
Well, I spent a couple of days throwing something together called nproc. It’s a node-based micro-server (express, jade, stylus) that you can run through npm that lets you define and manage these processes through a browser window. It saves your process definitions on the filesystem, so you can just:
npm install -g nproc nproc
and you’re up and running. Point your browser at http://localhost:3000 and you’ll see your processes waiting for you. Now you can start any or all of them simply by clicking the “Start” button next to it, and likewise stop it by clicking “Stop”. You can click on the name to see the output window for the process, or you can click on the menu lines to edit or delete the process.
One thing should catch your eye about that previous paragraph. You allowing anyone that can ping your machine,, the ability to define any process they want and execute it, on your machine. You, or someone else, can define “rm -rf /” and execute it. So, be aware of your surroundings, and never put this on a public-facing machine without the proper firewalls!
That’s it. It’s pretty simple. There’s a few small items I want to enhance, and some code I want to refactor, but I wanted something that doesn’t have to be fiddled with and just works.
Hopefully someone else will find it as useful as I do!