skip to Main Content

I have installed forever on shared hosting Cpanel for node js application when I run forever start app.js, node js application works on the server.

warn:    --minUptime not set. Defaulting to: 1000ms
warn:    --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info:    Forever processing file: app.js

But when I close terminal or console then node app stopped working. Any suggestions around it?

2

Answers


  1. Closing the terminal will typically close the application running. Consider using tmux or screen to launch the app or also nohup.

    Launching this way should be considered a short-term solution. You probably want to look at how your specific Linux distribution handles startup scripts and services.

    Login or Signup to reply.
  2. like maldina said closing forever will stop your app consider
    consider upstart (it runs tasks when the computer is started)
    you basiclly create a conf file and place it in your init folder "var/etc/init"
    the file content should look like this

    #!upstart
    description "my-app"
    
    start on started mountall
    stop on shutdown
    
    # Automatically Respawn:
    respawn
    respawn limit 99 5
    
    env NODE_ENV=production
    
    exec node /somepath/myapp/server.js >> /var/log/myapp.log 2>&1

    you can use the following commands to manage your app

    sudo start my-app
    sudo stop my-app
    sudo restart my-app
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search