Installation sequence fails: Django container exited unexpectedly
Tinggaard opened this issue · comments
Describe the bug
When installing the project, the installation script exits, with the message
[+] Waiting for Django application startup to complete...
2024/01/16 18:58:32 Django container exited unexpectedly. Check the logs in docker for the ghostwriter_django container
The application then seems to be running normally, but the credentials provided by ./ghostwriter-cli-linux config get admin_password
are invalid for the user admin
.
To Reproduce
Steps to reproduce the behavior:
- Run
./ghostwriter-cli-linux install
Expected Behavior
The application is expected to authenticate the user admin
with the password provided by ./ghostwriter-cli-linux config get admin_password
.
Furthermore the installer is not expected to crash.
Server Specs:
- OS: Ubuntu 22.04
- Docker:
Docker version 24.0.7, build afdd53b
Docker Compose version v2.19.1
- Ghostwriter: 4.0.5
Additional context
Logs from the container:
omited output of "Applying x.y... OK"
2024-01-16 18:58:32 Waiting for PostgreSQL to become available...
2024-01-16 18:58:33 Waiting for PostgreSQL to become available...
2024-01-16 18:58:34 PostgreSQL is available
2024-01-16 18:58:34 cp: can't preserve ownership of '/app/ghostwriter/media/templates/template.docx': Operation not permitted
2024-01-16 18:58:34 cp: can't preserve ownership of '/app/ghostwriter/media/templates/template.pptx': Operation not permitted
2024-01-16 18:58:37 456 static files copied.
2024-01-16 18:58:39 Operations to perform:
2024-01-16 18:58:39 Apply all migrations: account, admin, api, auth, commandcenter, contenttypes, db, django_q, home, oplog, otp_static, otp_totp, reporting, rest_framework_api_key, rolodex, sessions, shepherd, sites, socialaccount, taggit, users
2024-01-16 18:58:39 Running migrations:
<omited output of "Applying foo.bar... OK">
2024-01-16 18:59:00 INFO: Uvicorn running on http://0.0.0.0:5000 (Press CTRL+C to quit)
2024-01-16 18:59:00 INFO: Started parent process [24]
2024-01-16 18:59:02 INFO: Started server process [28]
2024-01-16 18:59:02 INFO: Waiting for application startup.
2024-01-16 18:59:02 INFO: ASGI 'lifespan' protocol appears unsupported.
2024-01-16 18:59:02 INFO: Application startup complete.
2024-01-16 18:59:02 INFO: Started server process [29]
2024-01-16 18:59:02 INFO: Waiting for application startup.
2024-01-16 18:59:02 INFO: ASGI 'lifespan' protocol appears unsupported.
2024-01-16 18:59:02 INFO: Application startup complete.
2024-01-16 18:59:02 INFO: Started server process [26]
2024-01-16 18:59:02 INFO: Waiting for application startup.
2024-01-16 18:59:02 INFO: ASGI 'lifespan' protocol appears unsupported.
2024-01-16 18:59:02 INFO: Application startup complete.
2024-01-16 18:59:03 INFO: Started server process [27]
2024-01-16 18:59:03 INFO: Waiting for application startup.
2024-01-16 18:59:03 INFO: ASGI 'lifespan' protocol appears unsupported.
2024-01-16 18:59:03 INFO: Application startup complete.
docker ps
output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b5ef76d9b598 ghostwriter_production_queue "/entrypoint /start-…" About a minute ago Up About a minute (health: starting) ghostwriter-queue-1
be906ac59cb6 ghostwriter_production_nginx "/docker-entrypoint.…" About a minute ago Up About a minute (health: starting) 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp ghostwriter-nginx-1
e14ce0770f1d ghostwriter_production_graphql "docker-entrypoint.s…" About a minute ago Up 49 seconds (health: starting) 0.0.0.0:8080->8080/tcp, 0.0.0.0:9691->9691/tcp ghostwriter-graphql_engine-1
8370d8a71cca ghostwriter_production_django "/entrypoint /start" About a minute ago Up About a minute (health: starting) ghostwriter-django-1
4a3db5a6456c ghostwriter_production_postgres "docker-entrypoint.s…" About a minute ago Up About a minute (health: starting) 0.0.0.0:5432->5432/tcp ghostwriter-postgres-1
45c317d2f0b3 ghostwriter_production_redis "docker-entrypoint.s…" About a minute ago Up About a minute (health: starting) 6379/tcp ghostwriter-redis-1
The logs don't suggest there was an issue, but it looks like your Django container took a long time to start. Ghostwriter CLI checks to make sure the Django container is running before proceeding with the install. Docker showed the ghostwriter_django
was not running. Ghostwriter CLI assumed an error had occurred with the build and exited.
If you were able to reach the login page to try the admin account, Django eventually started successfully. However, your admin password won't work because Ghostwriter CLI sets that at the very end of the install.
If you're able to get to the login page, the application is running and you can create the admin account with this command. Then you can login with the initial password in your config file:
docker compose -f production.yml run --rm django python manage.py createsuperuser --no-input --role admin
That should get you in.
Thank you very much!
Your provided command resolved the issue 🚀
Turns out the default models (severities, finding types, etc.) are not injected either.
Is there a way to inject these in a similar way?
Running docker compose -f production.yml run --rm django /seed_data
seems to resolve this issue.
I was not able to find the source for the ghostwriter-cli-linux
command. Is it located in this repository, and are there any other steps related to the installation, that I may haved missed?
Yep, that's the way to seed the default database values. The install
command does that once Django is ready. The source for the CLI binaries is here: https://github.com/GhostManager/Ghostwriter_CLI