javascriptnode.jsnightmare

Run nightmare by pm2 or something like that on the server


How to run nightmarejs by pm2 or something like that on the server, because nightmare use the electron and electron need graphic now i'm using xvfb-run npm start, but this sol° needs that i stay connected by ssh to the server have you any suggest?


Solution

  • Use "screen". "Screen is a console application that allows you to use multiple terminal sessions within one window. The program operates within a shell session and acts as a container and manager for other terminal sessions, similar to how a window manager manages windows." (ref: info)

    apt-get install screen
    
    # Create a session called "my_app"
    screen -S my_app
    
    # Now you are inside another shell
    xvfb-run npm start
    
    # After that, you can detach the screen or close the connection
    

    When you want to connect again to the screen, you must use reattach option -r.

    screen -r my_app
    

    To list active screens:

    screen -ls
    

    More options and info about screen command:

    https://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/