Skip to content

Instantly share code, notes, and snippets.

@Iinksafe
Forked from waterflamev8/self-hosting.md
Created March 17, 2021 13:46
Show Gist options
  • Save Iinksafe/504ebdaf42153ef34c3eec193bda08dc to your computer and use it in GitHub Desktop.
Save Iinksafe/504ebdaf42153ef34c3eec193bda08dc to your computer and use it in GitHub Desktop.
Self-hosting Modmail

A Definitive Guide to Self-hosting Modmail

Setup
  1. Fork the repo (Best to make it private).
  2. Define a Procfile in the root of the directory and fill the contents with worker: python3 launcher.py.
  3. Create a new app on Heroku and deploy the repo you've just forked.
  4. Go to "elements" and install the PostgresQL and Redis add-ons to your new app.
Credentials
  1. Gather the credentials from the PostgresQL add-on.

  2. Go to your config file on your repo and fill in the following credentials:

    # Bot's token
    token = ""
    
    # ...
    
    # Do it unless you want Prometheus
    testing = True
    
    # ...
    
    # Postgres database credentials
    database = {
        # The fields come from the credentials generated
        "database": "",
        "user": "",
        "password": "",
        "host": "",
        "port": 5432,
    }
  3. Gather the credentials from the Redis add-on.

  4. Go to the config file and set ipc_channel = "" to any name e.g. ipc_channel = "modmail".

  5. Navigate to classes/bot.py and modify the redis_pool connection to this format: "redis://<host>:<port>", minsize=5, maxsize=10, loop=self.loop, db=0, password="<password>" (Parts in <> come from the add-on credentials).

  6. Deploy to your heroku app.

Database Schema

Note: Make sure you've defined yourself in the owners = [] list in config.py.

  1. Open up the schema.sql file cloned from the repo.
  2. Navigate to a channel and run the command =sql passing the argument as one table in the schema. You must do all the tables individually or the command will not run e.g. =sql CREATE TABLE public.preference ( identifier bigint NOT NULL, confirmation boolean NOT NULL, PRIMARY KEY (identifier) );.
Deployment
  1. Deploy all the changes to GitHub so that the app on Heroku will be updated.
  2. On the Heroku app navigate to the Resources tab and there you should see the worker appear under your Dynos.
  3. Click the pencil icon and enable the dyno and you are good to go! 🎉

Contributing

Want to contribute to this guide to support more platforms? Awesome! Just drop waterflamev8#4123 a DM on Discord or chat with me on the ModMail Support Server

Special Thanks

  • Josh133#0001(Heroku guide)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment