Sorry for slow response. I have now returned to this problem, but since I let it rest for a while I cannot even get back to the same point. To avoid all of this headache I might consider using warp drive! Could you recommend a guide or tutorial for implementing warp drive with an existing project?
Johan On Saturday, 12 August 2017 02:04:09 UTC+2, Graham Dumpleton wrote: > > Override the startup command in the container so that you are adding: > > --log-level info > > This will cause mod_wsgi to output additional log messages about why this > error may have occurred. It suggests that the daemon process crashed for > some reason. The additional log messages will confirm whether that was the > case. > > FWIW, you may be better building your own image from scratch. See example > in: > > https://www.youtube.com/watch?v=H6Q3l11fjU0 > https://www.slideshare.net/GrahamDumpleton/secrets-of-a-wsgi-master > > I don't really do anything with that base image you are using any more as > have better alternatives. > > If try using warp drive as described in that talk let me know and can > explain what you need to do to set up things. > > Graham > > On 12 Aug 2017, at 12:36 am, Johan Larsson Hörkén <[email protected] > <javascript:>> wrote: > > No I did not do that, but I finally figured out that it was a logical > problem with my code. I also added the console logging just in case. I > think I got stuff running and connecting, but now I get a cryptic error > message: > Truncated or oversized response headers received from daemon process > 'localhost:80': /tmp/mod_wsgi-localhost:80:1001/htdocs/robots.txt > > Now when it regards a specific problem I will include information about my > setup: > Host: Ubuntu 16.04 > Docker 17.06 > Python 3.5 > > My Django app is connected to a MySQL (8.0) db in a separate container, > setup as: > > docker run -p 3306:3306 --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw > -d mysql:latest > > > My project directory has structure: > -- my_project > > -- .whiskey > > -- action_hooks > > -- build > > -- server_args > > -- my_django_project > > -- Dockerfile > > -- fig.yml > > -- requirements.txt > > > > The my_django_project contains a htdocs created through collectstatic. > > My Dockerfile is: > FROM grahamdumpleton/mod-wsgi-docker:python-3.5-onbuild > > > USER $MOD_WSGI_USER:$MOD_WSGI_GROUP > > > My fig.yml is slightly configured to connect to the mysql container: > version: '3' > > services: > db: > image: some_mysql > web: > build: . > command: python3 manage.py runserver 0.0.0.0:8000 > volumes: > - .:/my_django_project > ports: > - "8000:80" > depends_on: > - db > > My requirements.txt file contains all my requirements, including Django, > mysql-connector and mysqlclient. The rest of the files are copied (modified > arguments) from the tutorial/example, and should not be any surprises. > > I build the project simply by running: > sudo docker build -t my_project . > > One thing that I have noticed causing a problem in my project is that I am > running custom MySQL queries from my Python code (thus the mysql-connector > and mysqlclient requirements), which I realise is not ideal. But I have > solved that by linking the MySQL container explicitly to the Django > container in the run command by: > sudo docker run -it --rm -p 8000:80 --name my_running_app --link > some_mysql my_project > And changing the Django app to use the database provided by localhost and > the custom MySQL queries to access the database through the some_mysql > containers IP address. Not sure if this is the most efficient way of > solving it, and a future improvement would be to refactor all MySQL queries > to use the Django interface, but I do currently not know how to refactor > that efficiently. > > I read somewhere that this might be a problem with the mod_wsgi or Apache > version, do you think a possible fix would be to explicitly change the > mod_wsgi version in the Dockerfile from grahamdumpleton/mod-wsgi-server? > > Johan > > > > > > > > On Thursday, 10 August 2017 20:56:12 UTC-4, Graham Dumpleton wrote: >> >> >> On 11 Aug 2017, at 9:44 am, Johan Larsson Hörkén <[email protected]> >> wrote: >> >> I have been struggling to deploy my Django project in a good way for a >> while now, and I am still a bit novice in Docker. I followed the steps on >> >> http://blog.dscpl.com.au/2014/12/hosting-python-wsgi-applications-using.html >> and >> the Django example. The build goes fine, but when I run it I get a 500 >> Server Error, with no error messages in the Docker prompt. I am not sure >> how to proceed, is there a way to get the wsgi logs, or is there an obvious >> step that I have missed? >> >> >> Can you show me the Dockefile you are using? >> >> Have you configured Django in the settings file to log to the terminal? >> >> LOGGING = { >> 'version': 1, >> 'disable_existing_loggers': False, >> 'handlers': { >> 'console': { >> 'class': 'logging.StreamHandler', >> }, >> }, >> 'loggers': { >> 'django': { >> 'handlers': ['console'], >> 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), >> }, >> }, >> } >> >> >> Graham >> > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <javascript:>. > To post to this group, send email to [email protected] <javascript:> > . > Visit this group at https://groups.google.com/group/modwsgi. > For more options, visit https://groups.google.com/d/optout. > > > -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/modwsgi. For more options, visit https://groups.google.com/d/optout.
