OSX launchd plist for node forever process

前端 未结 5 506
旧时难觅i
旧时难觅i 2021-02-03 12:24

I am trying to write a launchd.plist file for my node server. I am using forever to run my node server. I would like the server to start on boot. I would also like to wait fo

5条回答
  •  旧时难觅i
    2021-02-03 12:59

    I had this problem too, but I solved it using an Automator app that runs at startup.

    1. Open Automator and choose, New Application

    2. Insert in your workflow "Run Shell Script"

    3. Use this code in the shell script, changing the paths to your paths

    export PATH=/usr/local/bin/:$PATH
    cd /path/to/your/nodejs/app
    forever start app.js
    
    1. Go to System Preferences >> User & Groups and click on Login Items tab

    2. Add your Automator app and be happy.

    The important part of the solution is the first line of the script (adding your bin to the path). It would probably work to add a Startup Item pointed at a bash script too (and no Automator script), feel free to try!

提交回复
热议问题