Using pm2 to manage silverbullet

Hey there,

I am new to this and I’ve read all the docs. I first tried the silverbullet docker option and was able to run the container. I also managed to start the container with “pm2”. Yet I was not able to close it. Could it be that SIGKILL is not send to this /tini process inside the docker container?

Then I tried installng it with deno, which also worked. Yet now I was not able to run it with pm2. I get these output in the logs:

 # generated by deno install
 SyntaxError: Invalid or unexpected token
     at internalCompileFunction (node:internal/vm:128:18)
     at wrapSafe (node:internal/modules/cjs/loader:1279:20)
     at Module._compile (node:internal/modules/cjs/loader:1331:27)
     at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
     at Module.load (node:internal/modules/cjs/loader:1205:32)
     at Module._load (node:internal/modules/cjs/loader:1021:12)
     at Object.<anonymous> (/home/USER/.nvm/versions/node/v21.7.3/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
     at Module._compile (node:internal/modules/cjs/loader:1368:14)
     at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
     at Module.load (node:internal/modules/cjs/loader:1205:32)

So is it even possible to manage the silverbullet process in any way with pm2? Thanks for any help!

I don’t know of anybody doing this, but it seems that pm2 does not seem to support running executables that are actually shell scripts (which is what the silverbullet script is), can that be a hint of how to address it?

Hey Zef, thanks for your reply. Actually pm2 is capable of managing shell scripts, after all. At least according to my testings.

Is there anyway of altering the docker container to apply the (maybe helping) -p flag to /tini?

Not from the outside, you can clone the repo, change the Dockerfile and rebuild the image. there’s ./scripts/ from the top of my head.

I got no notification per mail that you answered again. Sorry (I hate when such thing happen, argh!).

Thanks for your reply. I will see if I am able to rebuild the image myself etc. Thanks again; and sorry for the late reply!

Well when trying to build the docker on my own I got errors for files under /dist in the repo folder, which doe not exist.

I still do not know why the silverbullet executable nor the script, conatining the command, won’t work in PM2. It gives the above quoted error message. Do you understand the error message?

Hm, maybe nevermind: I might have managed to let it run with pm2. For everybody else getting trouble running silverbullet with pm2, here is the part of my ecosystem.config.js, while the important part here was to set interpreter: "none":

    name: 'silverbullet',
    script: 'silverbullet',
    interpreter: "none",
    args: '/home/USER/docs -p3000 --user USER:PASSWORD'

While USER and PASSWORD shoule be replaced, obiously.

1 Like