• As a newbie with zero development access, I followed the dummies guide below

    It was a miracle but I got the nodebb up and running successfully (I am good at following instructions).

    Here are some issues I am facing. Hope somebody can help.

    When I close my putty window, the server stops running and the forum is no longer accessible.

    How do I start the server and exit the terminal window?

    I know this sounds like a dumb questions but please bear with me.

  • Basic linux method would be to put & at the end of the command you use to start it, like;
    ./nodebb start &

    More information on that method can be found here http://www.cyberciti.biz/faq/linux-command-line-run-in-background/

    I currently use upstart to run it in background and have it auto startup on box restarting. My nodebb.conf script located in /etc/init looks like this;

    # An example upstart script for running a Node.js process as a service
    # using Forever as the process monitor. For more configuration options
    # associated with Forever, see: https://github.com/nodejitsu/forever
    # You will need to set the environment variables noted below to conform to
    # your use case, and should change the description.
    description "Example upstart script for a Node.js process"
    start on startup
    stop on shutdown
    # This line is needed so that Upstart reports the pid of the Node.js process
    # started by Forever rather than Forever's pid.
    expect fork
    # The following environment variables must be set so as to define
    # where Node.js and Forever binaries and the Node.js source code
    # can be found.
    # The example environment variables below assume that Node.js is
    # installed into /home/node/local/node by building from source as outlined
    # here:
    # https://www.exratione.com/2011/07/running-a-nodejs-server-as-a-service-using-$
    # It should be easy enough to adapt to the paths to be appropriate to a
    # package installation, but note that the packages available for Ubuntu in
    # the default repositories are far behind the times. Most users will be
    # building from source to get a more recent Node.js version.
    # The full path to the directory containing the node and forever binaries.
    # env NODE_BIN_DIR="/home/node/local/node/bin"
    # Set the NODE_PATH to the Node.js main node_modules directory.
    # env NODE_PATH="/home/node/local/node/lib/node_modules"
    # The directory containing the application Javascript file.
    # env APPLICATION_DIRECTORY="/home/node/my-application"
    # The application start Javascript filename.
    # env APPLICATION_START="start-my-application.js"
    # Log file path.
    # env LOG="/var/log/my-application.log"
    env NODE_ENV="development"
    env NODE_BIN_DIR=""
    env NODE_PATH=""
    env APPLICATION_DIRECTORY="/home/user/nodebb"
    env APPLICATION_START="app.js"
    env LOG="/home/user/nodebb/logs/nodebb.log"
        # Add the node executables to the path, which includes Forever if it is
        # installed globally, which it should be.
        # The minUptime and spinSleepTime settings stop Forever from thrashing if
        # the application fails immediately on launch. This is generally necessary $
        # avoid loading development servers to the point of failure every time
        # someone makes an error in application initialization code, or bringing do$
        # production servers the same way if a database or other critical service
        # suddenly becomes inaccessible.
        exec forever --sourceDir $APPLICATION_DIRECTORY -a -l $LOG \
             --minUptime 5000 --spinSleepTime 2000 start $APPLICATION_START
    end script
    pre-stop script
        # Add the node executables to the path.
        # Here we're using the pre-stop script to stop the Node.js application
        # process so that Forever is given a chance to do its thing and tidy up
        # its data. Note that doing it this way means that each application that
        # runs under Forever must have a different start file name, regardless of
        # which directory it is in.
        exec forever stop $APPLICATION_START >> $LOG
    end script

    Blatantly stolen from here https://www.exratione.com/2013/02/nodejs-and-forever-as-a-service-simple-upstart-and-init-scripts-for-ubuntu/ .

    This method allows me to type start nodebb and stop nodebb for quick restarting.

    There are other ways to do this, but I found this to be my favorite method.

  • dumb it down a little for me...

    so basically when I type "$ node app" the system runs the app and its 'stuck' because the app is perpetually running.

    When do I need to modify the command to? Is it "$ node app start &"

  • You could also install forever

    npm install -g forever
    cd /path/to/nodebb
    NODE_ENV=development forever start app.js

    (Replace NODE_ENV=development with NODE_ENV=production if you want to deploy it to production environment)

  • @BarveyHirdman said:

    You could also install forever

    npm install -g forever
    cd /path/to/nodebb
    NODE_ENV=development forever start app.js

    (Replace NODE_ENV=development with NODE_ENV=production if you want to deploy it to production environment)

    Thanks, I am running forever now. Seems to work.

Suggested Topics

| | | |