Create a new Session - pm2:
-
tmux works well for most enviornments, however, we can use pm2 which allows us to have more control and also more automation.
-
pm2 requires NodeJS/npm. If you don't have these already, you can get them the following ways:
Ubuntu/Debian systems can use curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install -y nodejs
to install NodeJS.
CentOS and RHEL users can use curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
and then run yum -y install nodejs
as root.
This will install the latest version of NodeJS and npm. There is a good chance you have them already, however.
-
After this, we can install pm2 simply:
npm install pm2 -g
-
We now want to start Nadeko. This part requires you to make the decision whether you want the auto-update on restart or the start normally without updating - also, if you want the
.die
command (auto-restart) without updates. -
You should have these files already, but if not, depending on which option you choose you'll need to use a different script. For the auto-restart without updating option, you can
wget https://raw.githubusercontent.com/Kwoth/NadekoBot-BashScript/1.9/NadekoARN.sh
if you don't have it already. For the auto-restart and update option, you canwget https://raw.githubusercontent.com/Kwoth/NadekoBot-BashScript/1.9/NadekoARU_Latest.sh
- and for the normal start without auto-restart on.die
, you canwget https://raw.githubusercontent.com/Kwoth/NadekoBot-BashScript/1.9/nadeko_run.sh
-
Now, simply type the following command
pm2 start [your chosen startup script.sh] --interpreter bash --name "Nadeko"
For example, if we want the auto-restart without updating option, we type pm2 start NadekoARN.sh --interpreter bash --name "Nadeko"
-
This will now start Nadeko as a pm2 process, and automatically manage restarts as well.
-
For the last step to take full advantage of pm2, we can run
pm2 startup
- on most Linux systems this issystemd
, sopm2 startup systemd
followed bypm2 save
will now save your pm2 processes and even if your server/VPS goes down and has to reboot, pm2 will automatically boot up and start Nadeko. -
The other benefits are easy stopping of the bot: simply type
pm2 status
and find the "process ID" or name of the bot, in this case Nadeko, and one can dopm2 stop [process ID or name]
andpm2 start [process ID or name]
-- this is great for easy updating. -
We can also get logs anytime:
pm2 logs [process ID or name]
will give a short log, but you can do something likepm2 logs [process ID or name] --lines 1000
to get a large output of the log. This is very helpful. -
This gives us a lot of control, and pm2 comes in handy for many other things! Although a bit more work to setup initially, it's worth the benefit in the long-run.