How to run meteor on startup on Ubuntu server

前端 未结 3 562
[愿得一人]
[愿得一人] 2021-02-06 09:03

I learn meteorjs and I have a small remote VPS.

I want:

  1. Set auto pulling from git repository my meteor project.
  2. Put script into auto start which r
3条回答
  •  有刺的猬
    2021-02-06 09:08

    Here is what I do:

    description "meteor app server"
    start on runlevel [2345]
    stop on runlevel [06]
    respawn
    respawn limit 10 5
    pre-start script
       set -e
       rm -f /path/to/your/app/.meteor/local/db/mongod.lock
    end script
    exec /bin/su - ec2-user -c '/path/to/your/app/meteor_server.sh'
    post-stop script
        pkill -f meteor
    end script
    

    The meteor_server.sh script contains:

    cd /path/to/your/app/; meteor run -p 3000 --production
    

    Make sure to chmod +x the meteor_server.sh script and change the path to your app in the 3 locations. The script also kills all meteor tasks when it is stopped so it works for running a single meteor app only on your server. I got a meteor app running quickly this way using nginx but node seems to consume a lot of memory.

提交回复
热议问题