Search code examples
deploymentvpspleskdiscord.js

Deploy Discord bot on vps (Plesk)


I have recently created a Discord bot in Javascript. I have bought a vps (Ubuntu 16.04 LTS Plesk Web Host) and a domain name. How do I run a Discord Bot 24/7 on this server? I have tried putting the app.js in a subdomain but that of course didn't seem to work... I have enabled node.js

Thanks in advance!


Solution

  • Solved the problem! I've downloaded Jenkins so it automatically deploys. After that I deploy it using forever. If someone wants to do this too, here is the script for jenkinsfile:

    pipeline {
      agent any
    
      tools {nodejs "node"}
    
      stages {
          stage('start node') {
            steps {
                sh 'npm --prefix ./src install ./src'
                sh 'JENKINS_NODE_COOKIE=dontKillMe forever stop ./src/app.js || true'
                sh 'JENKINS_NODE_COOKIE=dontKillMe forever start ./src/app.js'
            }
         }
      }
    }