Deploy Code Updates - MLROOTC/MLR-OOTC GitHub Wiki

You'll need:

  • Putty
  • WinSCP
  • Access to the server's IP address, username, and password, all of which can be found in the Passwords doc in the Internal OOTC Docs folder in Google Drive

Discord Bot Updates

  1. Review the files changed in the recent changes from a Merge Request. Download those files onto your pc.
    1. Make special note of any changes to config.ini.
    2. Any script change that imports a module as "src.Cogs." needs to be changed to "Cogs." due to the file structure on the host.
  2. Using WinSCP or similar program, log into the host.
    1. Credentials to log into the bot can be found on Vultr.com's website. Use the provided IP, provided userID and password saved in ootc's password document. Userid and Password can also be found on Vultr's website.
  3. Patch the files that need updating in their appropriate folders. Log out of WinSCP.
  4. Login to Vultr.com and go to the server detail page.
  5. Open up the web browser console on the top right of the page.
    1. If user has been logged out of the console, login the same way you did for WinSCP.
  6. Enter jobs into the console to see the scripts currently running in the background.
  7. type fg # where # is the job# for the scipt discord_bot.py.
  8. Press Ctrl+C to end the process.
  9. Start the bot up by entering the command:
    1. sudo python3 discord_bot.py &
  10. Test the bot to see if the patch was accepted. Close the console if so.

Restarting the Bot

  1. Log into the bot server via PuTTy
  2. Run ps -ef to get the list of running processes
  3. Locate sudo python3 discord_bot.py on the list and note the process ID
  4. Run kill #### with the #### being the process ID of the bot
  5. Run ps -ef again to make sure the process is actually stopped
  6. cd into the OtterBot directory
  7. Start the process again using sudo python3 discord_bot.py &

Restart Ump Pings

To stop the ump ping script, run the following command:
systemctl stop restart_ump_pings

To start the ump ping script, run the following command:
systemctl start restart_ump_pings

Website Updates

  1. Open a connection to the server with WinSCP
  2. Navigate to /root/var/www/swing420/website
  3. If any of the .py files have changed, drag and drop them in this directory
  4. Navigate to the /templates folder
  5. If any html files have changed, drag and drop them here
  6. We need to restart the apache server
  7. Open Putty
  8. Enter the IP address of the server under HostName
    1. It would be a good idea to enter a name for this session and save it into your Saved Sessions list
  9. Click Open or double click your saved session
  10. A command window should pop up. Type root when prompted for a username and hit enter
  11. Copy the password to your clip board, then right click in the command window to paste and hit Enter.
    1. You will not be able to see that anything has been typed in the command window.
    2. If you have logged in successfully the command window will say root@fakebaseball:~#
  12. If you needed to make changes to the Apache config, you'll need to restart Apache.
    1. systemctl reload apache2
  13. Restart the web server using the following command:
    1. sudo service apache2 restart
  14. That should be it. You can now log out by closing the Putty and WinSCP windows and pat yourself on the back for a job well done.

Create a Daemon to Run Script

  1. Create a file called .service
    Ex: restart_ump_bot.service
    In the file:
[Unit]
Description=Restart FakeBaseballBot

[Service]
Type=simple
WorkingDirectory=/root/OtterBot
ExecStart=/usr/bin/python3 /root/OtterBot/reddit_watcher.py
User=root
Restart=always

[Install]
WantedBy=multi-user.target

  1. Copy file to /etc/systemd/system/
  2. Issue following commands
    systemctl daemon-reload
    systemctl enable <name of the file without the .service extension>
    systemctl start <name of the file without the .service extension>
  3. To stop the process and auto restart:

systemctl stop <name of the file without the .service extension>

Reference

⚠️ **GitHub.com Fallback** ⚠️