• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

startup nodebb after server reboot

Scheduled Pinned Locked Moved Solved General Discussion
7 Posts 4 Posters 140 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    josef Translator
    wrote on last edited by
    #1

    What is the best way to configure nodebb to start automatically after restarting the server?
    I did it with pm2 -

    pm2 start app.js --name "nodebb"
    

    and then

    pm2 startup
    

    The disadvantage of this is that it is not possible to restart through the ACP, only using pm2 restart nodebb
    What is the right way to do it?

    1 Reply Last reply
    0
  • FrankMF Offline
    FrankMF Offline
    FrankM
    wrote on last edited by FrankM
    #2

    I start my Nodebb with systemd on Debian Bookworm 12.

    [Unit]
    Description=NodeBB
    Documentation=https://docs.nodebb.org
    After=system.slice multi-user.target mongod.service
    
    [Service]
    Type=forking
    User=USER
    
    StandardOutput=syslog
    StandardError=syslog
    SyslogIdentifier=nodebb
    
    WorkingDirectory=/home/USER/nodebb
    PIDFile=/home/USER/nodebb/pidfile
    ExecStart=/usr/bin/node loader.js
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    

    And restart from ACP works fine.

    J 1 Reply Last reply
    3
  • J Offline
    J Offline
    josef Translator
    replied to FrankM on last edited by josef
    #3

    @FrankM Thanks! Could you maybe elaborate on how I use it? I don't know enough about systemd
    Do I have to save it as a file in a certain location?

    1 Reply Last reply
    0
  • FrankMF Offline
    FrankMF Offline
    FrankM
    wrote on last edited by
    #4

    Create an file

    /etc/systemd/system/nodebb.service
    

    Stop your nodebb and then start it with

    systemctl enable nodebb.service
    systemctl start nodebb.service
    

    More to read -> https://docs.nodebb.org/configuring/running/

    1 Reply Last reply
    3
  • 陈 Offline
    陈 Offline
    陈洁
    wrote on last edited by 陈洁
    #5

    It can be combined with systemctl and tmux for script startup, it is very convenient tmux a can go back to the background to see real-time logs

    Here's my server startup script for reference, tmux is too convenient for me!

    #!/bin/zsh
    
    # Define the function that sends the command
    send_command() {
        tmux send -t $1 $2 Enter
    }
    
    # Close and delete the tmux session named "db".
    tmux kill-session -t "db"
    
    # Create a tmux session named "db".
    tmux new -t "db" -d
    tmux rename-window -t "db:1" "mongod"
    
    # n the "mongod" pane, execute the command
    send_command "mongod" "cd /home/web/MongoDB/bin/ && ./mongod --config ./mongo.conf"
    
    # Creating Horizontally Split Panes
    tmux split-window -h -t "db:mongod" -d
    tmux select-window -t "db:mongod"
    tmux select-pane -t "2"
    
    # Close and delete the tmux session named "nodebb".
    tmux kill-session -t "nodebb"
    
    # Create a tmux session called "nodebb".
    tmux new -t "nodebb" -d
    tmux rename-window -t "nodebb:1" "grunt"
    
    # Execute the command in the "grunt" pane.
    send_command "nodebb" "cd /home/web/NodeBB/ && ./nodebb slog"
    
    # Creating Horizontally Split Panes
    tmux split-window -h -t "nodebb:grunt" -d
    tmux select-window -t "nodebb:grunt"
    tmux select-pane -t "2"
    
    
    exit 0
    
    [Unit]
    Description=Startup Script
    After=network.target
    
    [Service]
    Type=forking
    Environment=TERM=xterm-256color
    ExecStartPre=/usr/bin/zsh -c 'source $HOME/.zshrc'
    ExecStart=/root/auto_script/startup.sh
    User=root
    Group=root
    
    [Install]
    WantedBy=multi-user.target
    
    julianJ 1 Reply Last reply
    2
  • J Offline
    J Offline
    josef Translator
    wrote on last edited by josef
    #6

    Thanks to everyone who helped!
    While implementing the solution provided by @FrankM I noticed that the file being loaded is loader.js and not app.js, and when I ran loader.js with pm2 (pm2 start loader.js --name "nodebb"), restarting from ACP works great!
    So maybe on another occasion I'll try the clean systemd method
    At the moment I prefer to continue using pm2 as a central tool for all the apps on my server, including nodebb 🙂
    Thanks again 👍

    1 Reply Last reply
    2
  • J josef marked this topic as a question on
  • J josef has marked this topic as solved on
  • julianJ Offline
    julianJ Offline
    julian GNU/Linux
    replied to 陈洁 on last edited by
    #7

    @陈洁 wow, that is definitely a power user setup!

    One thing I have struggled with is proper logging with systemd. At some point it seemed to stop emitting logs properly, and I could only either have logs sent to the journal for viewing with journalctl, or output to the regular log file at logs/output.log, not both. 🤷

    Regardless, @josef I'm glad you got it working 😄

    1 Reply Last reply
    1

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development