How to view gunicorn output for an app that's already running? - terminal

I am running a Flask/python app on a website in my terminal using:
gunicorn --workers 4 --bind :5000 app:app
It shows me the log but it eventually times out, even though the website is still up and running. Is there a way I can go back to viewing the log?
So far, I can only go back to seeing the log by running sudo reboot
for the Ubuntu server and then reopening the server with ssh and running the gunicorn code again.

Related

webserver is shut down when Apache/AirFlow docker containers are started from local machine

I am trying to set up a development environment for Apache/AirFlow on MacBook with macOS 10.14.x.
I have installed docker, virtualbox and created virtual machine and created containers with web_server, worker, scheduler and redis, postgres.
I run :
docker-compose up -d
But, when I visited http://localhost:8080, I got:
This page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE
In the docker-compose log file, I found:
[mwebserver_1 [INFO] Parent changed, shutting down: <Worker 34>
[mwebserver_1 [INFO] Worker exiting (pid: 34)
[mwebserver_1 {{cli.py:815}} ERROR - No response from gunicorn master within 120 seconds
[mwebserver_1 {{cli.py:816}} ERROR - Shutting down webserver
I am not sure what the problem could be.
Any suggestions would be appreciated.
After start the docker container's.
Try to run docker exec -it NAME_OF_CONTAINER /bin/bash. After that you're gonna into container bash and you can run airflow webserver.

Not able to connect to an app running on a docker container via browser in mac

I was trying to running a docker image from a gitlap repository as mentioned in https://codebabel.com/ci-gitlabci-docker/
I ran the image as shown below and it started
docker run -p 5000:50000 -it registry.gitlab.com/bacdef/flaskapp:latest
* Serving Flask app "helloworld" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 259-006-586
But when I try to access it via browser http://127.0.0.1:5000/ or http://localhost:5000/ or http://myip:5000/ it reply as follows
This page isn’t working 127.0.0.1 didn’t send any data.
ERR_EMPTY_RESPONSE
docker ps command output ias as follows
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
04cc5dc26ec5 registry.gitlab.com/bacdef/flaskapp:latest "python helloworld.py" 18 minutes ago Up 18 minutes 0.0.0.0:5000->50000/tcp hardcore_perlman
I am running it on a mac os.
Tried solution of similar questions like How to access webserver running in docker container from browser?, https://superuser.com/questions/1204030/cannot-access-to-http-localhost4000-after-i-map-this-port-number-to-docker but it does not work.
Can somebody please suggest what am I doing wrong?

How to look Gunicorn logs when it running?

I deployed a Flask application to a VPS, and using Gunicorn as a web server.
And I running the Gunicorn server using this command:
gunicorn --bind=0.0.0.0 run:app --access-logfile '-'
With the command I can see the log running. But after I closed my terminal session, I want to see the running logs again.
In Heroku I can use heroku logs -t to do that, any similar way to see it on Gunicorn..?
You need to set up the supervisor. Supervisor keeps your server running mode and saves your log. setup the supervisor file below and then you can see the logs:
[program:your_project_name]
command=/home/your_virualenv/bin/gunicorn --log-level debug
run_apiengine:main_app --bind 0.0.0.0:5007 --workers 2 --worker-class gevent
directory=your_project_directory
stdout_logfile= your_log_folder_path/supervisor_stdout.log
stderr_logfile= your_log_folder_path/supervisor_stderr.log
user=your_user
autostart=true
PYTHONPATH="$PYTHONPATH:your_python_path";OAUTHLIB_INSECURE_TRANSPORT='1';

RabbitMQ console returned 431

I start rabbitmq on docker with command:
docker run -d --hostname my-rabbit --name rabbit-fox -p 5672:5672 -p 8090:15672 rabbitmq:3-management
it runs fine and i can log into console, but later on Chrome browser i get this:
and can not use then console in the browser.
Clearing browser's cache & memory did the work in my case.
After facing the same issue these steps performed:
I tried to re-run the docker, even I got to the point I re-installed the RabbitMQ server image without any result.
It simply was solved when I cleared the browser's Cache & Memory

PyCharm debugger stopping containers after "Waiting for connection" ends

I am trying to debug docker-compose containers in PyCharm.
Here is how my run configuration looks like:
Note that it is a Django app. When I try to start the debugger it is successfully starting all containers and I can access the app on the browser for a short amount of time. Also there is a background task running "Waiting for connection"
Right after it ends, the containers are suddenly stopped.
What am I doing wrong?
Here is what I did to fix this:
Moved the entrypoint to the docker-compose file instead of the Dockerfile
Changed the port to 8000 from 8050
I have no idea why this matters but it fixed it.

Resources