ZioMark's HUB

What's PM2 and Why We Use It

The process manager that keeps our services running, even when we're not watching.

What's PM2 and Why We Use It
What's PM2 and Why We Use It ZioMark

When people start building Discord bots, web dashboards or any Node.js application, the first thing they usually do is open a Command Prompt window and run:

  node index.js

It works. Until it doesn't.

The moment that terminal closes, Windows restarts, or something unexpected happens, your application is gone. If you're lucky, you'll notice it immediately. If you're not, your users will notice before you do.

This is exactly where PM2 comes in.

PM2 is a process manager for Node.js applications. In simple words, it's a tool that keeps your applications alive. If one of them crashes because of an unexpected error, PM2 automatically starts it again. If the server reboots, PM2 can bring everything back online without you touching a single button.

I like to explain it with a simple example:

Imagine a spinning wheel. If you spin it by hand, it will keep turning for a while, but eventually it slows down and stops. Every time that happens, someone has to walk over and spin it again.

Running an application from a normal Command Prompt is exactly like that.

PM2 is the person standing next to the wheel all day long. The moment it slows down, it gives it another push. You don't have to be there. It simply keeps everything moving.

This becomes especially important for Discord bots.

A Discord bot is expected to be online 24 hours a day. If it goes offline, commands stop working, moderation features disappear, music bots stop playing, and your community immediately notices something is wrong.

Without PM2, every crash means manually reconnecting to the server, opening a terminal and starting the bot again.

With PM2, most crashes are solved before you even realize they happened.

The same applies to web dashboards and APIs.

Many of my personal projects expose APIs or web interfaces that need to be available all the time. If a dashboard suddenly goes offline because of an unexpected exception, users can't access their data anymore. PM2 continuously watches those applications and restarts them whenever necessary.

Another practical advantage is that you no longer need six different Command Prompt windows scattered across your desktop.

Instead of something that looks like this:

  Bot #1
Bot #2
Bot #3
Dashboard
API
Webhook Service

You simply have PM2 managing every service from one place.

You can instantly see which applications are running, restart one without affecting the others, check memory usage, inspect logs and even configure applications to start automatically whenever the server boots.

One thing I personally experienced on Windows is that leaving applications running inside a Command Prompt for weeks isn't always reliable. Sometimes the console becomes unresponsive, sometimes an application appears frozen, and in general it's just not something I would trust for production services.

PM2 removes that dependency on an open terminal. Once your applications are registered, they run as managed processes instead of depending on a console window that has been open for days or weeks.

For me, PM2 has become one of the first tools I install on every Windows Server or VPS.

Today I use it to manage Discord bots, internal APIs, Next.js dashboards, automation services and other Node.js applications. Everything is centralized, automatically restarted when needed, easy to monitor and much easier to maintain than manually keeping multiple terminal windows open.

Can you run Node.js applications without PM2? Absolutely.

Should you, if the application is important and expected to stay online Probably not.

Once you've used PM2 for a while, going back to manually opening Command Prompt windows feels like going back to manually restarting your Wi-Fi router every time your internet disconnects. It works, but there's simply a better way.

Subscribe to "ZioMark's HUB" to get updates straight to your inbox
ZioMark

Subscribe to ZioMark to react

Subscribe

Comments

No comments yet. Be the first to comment!

Subscribe to ZioMark's HUB to get updates straight to your inbox