Keep meteor running on amazon EC2

前端 未结 3 1735
野趣味
野趣味 2020-12-06 14:55

I have a simple meteor app that I\'m running on an Amazon EC2 server. Everything is working great. I start it manually with my user via meteor in the project

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-06 15:33

    Install forever and use a start script.

    $ npm install -g forever
    

    I have several scripts for managing my production environment - the start script looks something like:

    #!/bin/bash
    
    forever stopall
    
    export MAIL_URL=...
    export MONGO_URL=...
    export MONGO_OPLOG_URL=...
    export PORT=3000
    export ROOT_URL=...
    forever start /home/ubuntu/apps/myapp/bundle/main.js
    
    exit 0
    

    Conveniently, it will also append to a log file in ~/.forever which will show any errors encountered while running your app. You can get the location of the log file and other stats about your app with:

    $ forever list
    

    To get your app to start on startup, you'd need to do something appropriate for your flavor of linux. You can maybe just put the start script in /etc/rc.local. For ubuntu see this question.

    Also note you really should be bundling your app if using it in production. See this comparison for more details on the differences.

提交回复
热议问题