Hey non-existent readers, it's been a while. In fact, it was a year ago that I made my last post, so I figure it's time for an update.

I wanted to do a quick update! I've been pretty silent recently because I've been working for this super awesome (formerly super secret) company called Starry Internet. I've joined their UI/Web team where I'm working across the stack to create really awesome infrastructure using the latest node, building web apps that are customer facing, and the list keeps growing as the company expands. I'm really excited to be here, and I get to work with some really awesome people on some really awesome projects.

So I'm getting back into the habit of writing a bit about the life of a junior developer trying to level up as fast as he can. Hopefully these roadblocks that I've run into will be at least marginally beneficial to others who've tried the same thing with no luck using the Google, but either way, it helps me to re-understand my own work, so I'm selfish. Deal with it.


PM2

Dumb mistakes with npm, and how to make them

So I relatively recently discovered PM2 (a process manager to help you run a bunch of services in a bunch of configurations ) and I really enjoy the ease of setup and accessibility that it provides. The documentation is pretty great, and their Github is really active as well.

That being said, I've run into a few things that I wish were answered elsewhere, and I hadn't been able to easily find anyone trying to answer the same question I had: How do I tell PM2 to run npm start without being sent to this page and ultimately being told to run pm2 start npm -- start.

That totally works, and will result in you getting a process up and running with the name "npm", but everything will be running. Can't really complain, right?

Wrong.

One of my favorite parts about PM2 is the idea that you can use a process file (JSON) to tell it how to spin things up. It's super convenient, reusable, and verbose, especially when looking at using the CLI to do things with a list of parameters. For the life of me, I couldn't get this to work correctly, but I'll give a template to anyone who feels like they want to use it:

// blog_process.json
{
  apps : [{
    name            : "Process_Name",
    script          : "/usr/local/bin/npm",
    args            : ["start", "--production"],
    cwd             : "./your_dir/"
  }]
}

This will result in getting the name you want, and you can specify exactly which parameters to use. There are a ton more configurations that are available, but this seemed to be the only one that allowed me to specify a name, as well as run everything in production.

After you've got your JSON file saved and configured properly, you can just head over to your root directory and run pm2 start blog_process.json and PM2 handles the rest.

Anyways, hope you found this helpful, and I hope to be writing more of these as I move forward in eating random things from the full stack.