diff --git a/Makefile b/Makefile index ee214f5..4a6c319 100644 --- a/Makefile +++ b/Makefile @@ -29,3 +29,15 @@ move-to: .PHONY: self-destruct move-to: -docker run --volume `pwd`/data:/app/data --volume `pwd`/app/static:/app/app/static microblogpub/microblogpub inv self-destruct + +.PHONY: reset-password +reset-password: + -docker run --volume `pwd`/data:/app/data --volume `pwd`/app/static:/app/app/static microblogpub/microblogpub inv reset-password + +.PHONY: check-config +check-config: + -docker run --volume `pwd`/data:/app/data --volume `pwd`/app/static:/app/app/static microblogpub/microblogpub inv check-config + +.PHONY: compile-scss +compile-scss: + -docker run --volume `pwd`/data:/app/data --volume `pwd`/app/static:/app/app/static microblogpub/microblogpub inv compile-scss diff --git a/docs/user_guide.md b/docs/user_guide.md index 5eea3a4..3714e95 100644 --- a/docs/user_guide.md +++ b/docs/user_guide.md @@ -33,6 +33,9 @@ Whenever one of these config items is updated, an `Update` activity will be sent The server will need to be restarted for taking changes into account. +Before restarting, you can ensure you haven't made any mistakes by running the [configuration checking task](/user_guide.html#configuration-checking). + + ### Profile metadata You can add metadata to your profile with the `metadata` config item. @@ -283,7 +286,7 @@ make account=username@domain.tld webfinger Edit the config. -#### Edit the config +### Edit the config And add a reference to your old/existing account in `profile.toml`: @@ -295,6 +298,61 @@ Restart the server, and you should be able to complete the move from your existi ## Tasks +### Configuration checking + +You can confirm that your configuration file (`data/profile.toml`) is valid using the `check-config` + +#### Python edition + +```bash +poetry run inv check-config +``` + +#### Docker edition + +```bash +make check-config +``` + +### Recompiling CSS files + +You can ensure your custom theme is valid by recompiling the CSS manually using the `compile-scss` task. + +#### Python edition + +```bash +poetry run inv compile-scss +``` + +#### Docker edition + +```bash +make compile-scss +``` + + +### Password reset + +If have lost your password, you can generate a new one using the `password-reset` task. + +#### Python edition + +```bash +# shutdown supervisord +poetry run inv password-reset +# edit data/profile.toml +# restart supervisord +``` + +#### Docker edition + +```bash +docker compose stop +make password-reset +# edit data/profile.toml +docker compose up -d +``` + ### Pruning old data You should prune old data from time to time to free disk space. @@ -388,3 +446,11 @@ poetry run inv self-destruct # For a Docker install make self-destruct ``` + +## Troubleshooting + +If the server is not (re)starting, you can: + + - [Ensure that the configuration is valid](/user_guide.html#configuration-checking) + - [Verify if you haven't any syntax error in the custom theme by recompiling the CSS](/user_guide.html#recompiling-css-files) + - Look at the log files diff --git a/tasks.py b/tasks.py index cfa9bf8..c8c5f30 100644 --- a/tasks.py +++ b/tasks.py @@ -327,3 +327,23 @@ def reset_password(ctx): print() print("Update data/profile.toml with:") print(f'admin_password = "{new_password}"') + + +@task +def check_config(ctx): + # type: (Context) -> None + import sys + import traceback + + from loguru import logger + + logger.disable("app") + + try: + from app import config # noqa: F401 + except Exception as exc: + print("Config error, please fix data/profile.toml:\n") + print("".join(traceback.format_exception(exc))) + sys.exit(1) + else: + print("Config is OK")