日誌2021-08-18 07:03
【discord.js (v13) BOT 製作筆記三】搭配雲端伺服器讓 BOT 24小時運作作者:游隼
curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo yum install -y nodejs
node -v
mkdir discord-bot
cd discord-bot
npm install discord.js @discordjs/rest discord-api-types
直接執行 BOT 不是不行,但一旦關掉 PuTTY BOT 就會一起被關掉
nohup node index.js &
所以用 nohup 讓程式執行在背景就可以不用一直連著甲骨文雲端 Server
直接執行 BOT 不是不行,但一旦關掉 PuTTY BOT 就會一起被關掉
nohup node index.js &
所以用 nohup 讓程式執行在背景就可以不用一直連著甲骨文雲端 Server
這點很重要,我之前用 nohup 開麥塊 Server 的時候都是直接按叉叉關閉 PuTTY,但這次在用 Discord Bot 的時候發現儘管已經 nohup 了,叉叉 PuTTY 之後 Bot 還是會被關掉。查了萬能的 stackoverflow 之後發現只要乖乖的用 exit 離開 PuTTY 就行了。
exit