Hosting on Digital Ocean


Server Setup & Maintenance:

Initial Server Setup

  • Start a digital ocean instance (with node as your image)
  • Generate and add SSH keys before creating (then you dont have to do it after)
  • get server IP address
  • connect via PuTTY
  • Run commands:
    • apt install unzip
    • npm install --no optional -g forever

Unpackage and Start the bot

  • Upload the bot file to your droplet using something like WinSCP
    • If you're uploading the bot for the first time it may be faster to upload is as a zip file and then unzip it on the dropletby typing unzip <yourbot>.zip -d <bot folder>
    • If you've already uploaded the bot and you're just making a change to the command.json/events.json file you can JUST upload those without zipping them
  • chmod -R a+rwx <bot folder>- Give the bot folder permission to be read/write and executable
  • cd <bot folder> - Change to the bots directory
  • forever start bot.js - Start the bot program using "Forever" (this will keep the bot running and restart it if it crashes)

Stop the bot

  • forever list
  • forever stop 0 - Where 0 is the index of your code in the forever list.

Server Maintenance

When you log into Digital Ocean you'll see an MOTD telling you if there are package updates. If you want/need to install them do the following:

Install Updates

When updates are available:

  • sudo apt update - update package index
  • sudo apt upgrade - install updates
  • sudo reboot - reboots the system (server will indicate if its needed)

add SSH key to server file manually

If you want to add an SSH key after you've set up your droplet you can edit the authorized_keys file

  • edit directly in PuTTY
    • nano /root/.ssh/authorized_keys
    • enter ssh-rsa <key> (the section that starts with AAAA[gibberish] - do not use begin, end, or comment line)
            ---- BEGIN SSH2 PUBLIC KEY ----
            Comment: "rsa-key-[date]"
            [a whole lot of gibberish]
            ---- END SSH2 PUBLIC KEY ----
      
    • ctrl + O, then at the bottom says "filename to write"
    • ctrl + x
  • set up PuTTY to connect automatically
    • in PuTTY - open the connection details
    • choose DATA
    • Fill in the Auto Login username
  • Putty should now connect automatically when the server is connected to

results matching ""

    No results matching ""