How to run meteor on startup on Ubuntu server

前端 未结 3 580
[愿得一人]
[愿得一人] 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:30

    You should use Ubuntu way, which is Upstart:

    http://upstart.ubuntu.com/ http://manpages.ubuntu.com/manpages/lucid/man5/init.5.html

    How to define daemon job:

    http://newcome.wordpress.com/2012/02/26/running-programs-as-linux-daemons-using-upstart/

    Hope it helps :)

    Your upstart file would be more or less:

    # meteorjs - meteorjs job file
    
    description "MeteorJS"
    author "Igor S"
    
    # When to start the service
    start on runlevel [2345]
    
    # When to stop the service
    stop on runlevel [016]
    
    # Automatically restart process if crashed
    respawn
    
    # Essentially lets upstart know the process will detach itself to the background
    expect fork
    
    # Run before process
    pre-start script
            cd PATH_TO_METEOR_APP
            echo ""
    end script
    
    # Start the process
    exec meteor run -p 80 --help -- production
    

提交回复
热议问题