launchd system permissions

I am launching PM2 using launchd. I register it like:


launchctl bootstrap system /Library/LaunchDaemons/pm2.root.list


After bootup, PM2 is setup to run a node.js app as root user. "pm2 list" confirms that indeed it is running as root. But the app fails to contact mongodb with a timeout! The app can download a homepage from the internet, so it is not because the app is missing access to the internet. If I login as root and run "pm2 restart node_app_id", the app is now able to contact atlas mongodb.


Does the "system" parameter when registering PM2 with launchd port-restrict my app somehow or what could be the issue here?


Thanks in advance

Mac mini (M1, 2020)

Posted on Aug 12, 2023 7:37 AM

Reply
Question marked as Top-ranking reply

Posted on Aug 15, 2023 8:57 PM

Found the solution. Posting it for anyone in the same situation.


Launchd does not assure network interface is up and running when launching your app. In your app, run a while loop that checks if you have internet. On success, connect to mongodb.

Similar questions

2 replies

Aug 15, 2023 6:08 AM in response to lassefromescobedo

lassefromescobedo wrote:

I am launching PM2 using launchd. I register it like:

launchctl bootstrap system /Library/LaunchDaemons/pm2.root.list

After bootup, PM2 is setup to run a node.js app as root user. "pm2 list" confirms that indeed it is running as root. But the app fails to contact mongodb with a timeout! The app can download a homepage from the internet, so it is not because the app is missing access to the internet. If I login as root and run "pm2 restart node_app_id", the app is now able to contact atlas mongodb.

Does the "system" parameter when registering PM2 with launchd port-restrict my app somehow or what could be the issue here?

Thanks in advance


Have you searched the documentation for insight to your third party...


https://pm2.keymetrics.io/docs/usage/pm2-doc-single-page/

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

launchd system permissions

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.