- Docker sends SIGTERM on `docker restart` and `docker stop`
- We need to cleanup the PID_FILE when this occurs so that when the container starts again the PID_FILE is not there
- Move logic to a function to KeyboardInterupt / SIGINT exit flow uses same cleanup as SIGTERM
- I also added a function to check in Linux only that if the PID stored isn't actually running we'll remove the file and allow gpt3discord to start
Test:
- Build a docker container and run + restart locally
- `docker build -t gpt3discord .`
- `docker run --name gpt3discord -v /containers/gpt3discord/env:/opt/gpt3discord/etc/environment -v /containers/gpt3discord/data:/data gpt3discord:latest`
- `docker restart gpt3discord`
See logs do what we need:
```
Commands synced
Killed all subprocesses
Removing PID file bot.pid
None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.
```
- Move Some environment loading code to EnvService.
- Attempt loading of env file from multiple locations & names
- Provide a path fetching + fallback function for reading
paths from environment vars.
- For Docker;
- Create /opt/gpt3discord/{etc,bin,shared}
- Copy .txt shared data into shared
- Copy main .py into bin
Refactored /g into /chat and /gpt-chat into /converse
Both have the grouping "gpt" so the full is /gpt chat, and /gpt converse
Added pycord-multicog to the project for easier slash grouping across cogs
Made the role check case insensitive and added some comments to the sample.env
Removed the rest of the discord.ext imports, it's not really used, ymmv
Removed another admin check i had missed in local-size
- Add a pyproject.toml to install all modules and packages
- Use hatch to build + install
- Still only claim support for 3.9
- We don't specify versions in pyproject.toml on purpose so people can have some flexibility there
- If they want the tested pinned versions they can use requirements.txt like Docker + CI does ...
- This will allow the package to be uploaded to PyPI if you'd like now :)
- `git mv main.py gpt3discord.py` as main.py is to common (incase someone installs to shared python env)
- Move initalization code into a init() function to have entry point script call
- Update `Dockerfile` to install via pyproject.toml
- Both docker + build CI install requirements.txt so we get the known versions of dependencies that work
- Update README for less steps now in installing
- Side note, we will have to track versions now and increment as we see fit - I'd like to discuss using GitHub releases here ...
- Sort requirements.txt to be alphabetical ...
Test:
- Add python 3.9 CI to install our module
- Paves the way to add more CI to help me test the module works in 3.11
- Build in a local venv
- `python3.9 -m venv /tmp/foovenv`
- `/tmp/foovenv/bin/pip install -r requirements.txt`
- `/tmp/foovenv/bin/pip install .`
- Build in docker
- `docker build -t gpt3discord .`