跪拜 Guibai
← Back to the summary

bm2: A 2.8 MB pm2 Replacement Written in MoonBit

Today I'm sharing a tool I wrote, bm2, a pm2 replacement implemented in MoonBit.

Repository: https://github.com/chenbimo/bm2.

Some might wonder, pm2 works fine, why replace it?

Note: Due to time constraints, the tool doesn't yet offer online installation or updates. For discussion, please contact me at the end of the article.

Why replace pm2?

pm2 is a veteran process management tool in the Node ecosystem, and it's indeed easy to use.

But I only use a few commands daily, while pm2 has dozens of commands — 90% of its functionality I never touch.

So I thought, could I write something lighter and simpler myself?

Thus, bm2 was born.

What is bm2?

In one sentence: bm2 is a pm2 replacement, specifically designed to manage projects running on Node.js and Bun.js in a Linux environment.

It's written in the MoonBit language, and the entire tool consists of just two files — grab them and go.

How simple is it to use?

First, write a config file to tell it where your app is:

# bm2.toml
[[apps]]
name = "api"
cwd = "/srv/api"
script = "index.ts"
instances = 2
base_port = 3000

Then start it with a single command:

bm2 start

Done.

How lightweight is it?

These are real measurements from my local machine:

Item Data
bm2 binary size 2.8 MB
Background service size 3.0 MB
Resident memory 2.7 MB
Command response 3 ms

One word: light.

The background service runs long-term, using less than 3 MB of memory — lighter than a web page.

Command response is 3 milliseconds, with no perceptible delay.

What can it do?

Why write it in MoonBit?

MoonBit is a relatively new programming language with very concise syntax.

How concise? Look at this example:

fn main {
  println("Hello, bm2!")
}

Its advantages directly correspond to the data above.

Honestly, using MoonBit to write this kind of small system-level tool is a very fitting combination.

Moreover, the MoonBit ecosystem is gradually growing — package management and build tools are quite complete, and the barrier to writing tools is getting lower and lower.

MoonBit Official Site https://www.moonbitlang.cn/

Final words

If you're also looking for a pm2 replacement — something lighter, simpler, and more worry-free for process management — give bm2 a try.

It's written in MoonBit, representing a real-world application of MoonBit in the system tools domain.

If this article was helpful, feel free to like, share, and comment to give me some support and encouragement. Thanks.

I wonder what you think? Feel free to leave a comment.

Thanks for reading. I'm Chen Suiyi, the Frontend Tiger. Public account 陈随易, personal website: https://chensuiyi.me.

Comments

Top 2 from juejin.cn, machine-translated. The original thread is authoritative.

黎大仙

Interesting. Now that I have AI, I'll use it to write one too.

亚雷

Lightweight process management is really eye-catching.