## A Definitive Guide to Self-hosting [Modmail](https://github.com/chamburr/modmail) ### [Heroku](https://heroku.com) ##### 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: ```python # 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://:", minsize=5, maxsize=10, loop=self.loop, db=0, 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](https://discord.com/invite/wjWJwJB) ### Special Thanks + Josh133#0001(Heroku guide)