I have a problem that when I want to turn on my discord bot on my server that uses cPanel, I can’t get it to work from the node.js control panel without putting the shell command node index.js
into the package.json file and using the run script function of the panel. the problem with this is that the only way to stop the bot is to use the eval command on discord, since I don’t have proper terminal access.
3
Answers
On cPanel you will never have full terminal access, so what I suggest you do is just keep the NPM start script, then create a command for the bot that issues the
process.exit()
function. This function essentially stops the entire NodeJS Process. If you are looking for an alternative that provides full terminal access I recommend buying a cheap VPS from a decent provider such as OVH.In addition to what @Verdigris answered above, you can use Glitch too, just make sure to use Runtime Bot so you can keep your Discord bot up 24/7.
And as always, cheers.
If your cPanel account has a in-browser terminal, you can enter the virtual environment by pasting the command that appears at the top of the Node.js control panel into there. It is something like:
You will then have access to node and npm, and can then start your discord bot like you normally would like:
and kill it by running
kill -TERM
with node’s pid, fromps -ax
.However, you can’t reliably use the Node.js panel to stop a daemon script, as described here:
cpanel node.js Can't acquire lock for app: app