I have a Flask app with the following route:
#app.route('/')
def index():
console = logging.StreamHandler()
log = logging.getLogger("asdasd")
log.addHandler(console)
log.setLevel(logging.DEBUG)
log.error("Something")
print >> sys.stderr, "Another thing"
return 'ok'
I run this using
python gunicorn --access-logfile /mnt/log/test.log --error-logfile /mnt/log/test.log --bind 0.0.0.0:8080 --workers 2 --worker-class gevent --log-level debug server:app
The Logs are as below:
2014-06-26 00:13:55 [21621] [INFO] Using worker: gevent
2014-06-26 00:13:55 [21626] [INFO] Booting worker with pid: 21626
2014-06-26 00:13:55 [21627] [INFO] Booting worker with pid: 21627
2014-06-26 00:14:05 [21626] [DEBUG] GET /
10.224.67.41 - - [26/Jun/2014:00:14:14 +0000] "GET / HTTP/1.1" 200 525 "-" "python-requests/2.2.1 CPython/2.7.5 Darwin/13.2.0"
2014-06-26 00:14:14 [21626] [DEBUG] Closing connection.
What's happening to my logs in index method?
As of Gunicorn 19.0, gunicorn has stopped redirecting stderr to its logs.
Refer to https://github.com/benoitc/gunicorn/commit/41523188bc05fcbba840ba2e18ff67cd9df638e9
Related
I have been trying the last couple days to build a nginx/gunicorn/flask stack in Puppet to deploy repeatedly in our environment. Unfortunately, I am coming up short at the last moment and could really use some help. I have dumped anything I though relevant below, if anyone can lend a hand it would be very helpful!
gunicorn cli errors
(pyvenv) [root#guadalupe project1]# gunicorn wsgi:application
[2022-12-01 15:07:29 -0700] [13060] [INFO] Starting gunicorn 20.1.0
[2022-12-01 15:07:29 -0700] [13060] [INFO] Listening at: http://127.0.0.1:8000 (13060)
[2022-12-01 15:07:29 -0700] [13060] [INFO] Using worker: sync
[2022-12-01 15:07:29 -0700] [13063] [INFO] Booting worker with pid: 13063
^C[2022-12-01 15:08:01 -0700] [13060] [INFO] Handling signal: int
[2022-12-01 15:08:01 -0700] [13063] [INFO] Worker exiting (pid: 13063)
[2022-12-01 15:08:01 -0700] [13060] [INFO] Shutting down: Master
(pyvenv) [root#guadalupe project1]# gunicorn wsgi:application -b project1.sock
[2022-12-01 15:08:09 -0700] [13067] [INFO] Starting gunicorn 20.1.0
[2022-12-01 15:08:09 -0700] [13067] [ERROR] Retrying in 1 second.
[2022-12-01 15:08:10 -0700] [13067] [ERROR] Retrying in 1 second.
[2022-12-01 15:08:11 -0700] [13067] [ERROR] Retrying in 1 second.
[2022-12-01 15:08:12 -0700] [13067] [ERROR] Retrying in 1 second.
[2022-12-01 15:08:13 -0700] [13067] [ERROR] Retrying in 1 second.
[2022-12-01 15:08:14 -0700] [13067] [ERROR] Can't connect to ('project1.sock', 8000)
gunicorn debug log from running
$ gunicorn wsgi:application -b project1.sock --error-logfile error.log --log-level 'debug'
[2022-12-01 15:28:04 -0700] [16349] [DEBUG] Current configuration:
config: ./gunicorn.conf.py
wsgi_app: None
bind: ['project1.sock']
backlog: 2048
workers: 1
worker_class: sync
threads: 1
worker_connections: 1000
max_requests: 0
max_requests_jitter: 0
timeout: 30
graceful_timeout: 30
keepalive: 2
limit_request_line: 4094
limit_request_fields: 100
limit_request_field_size: 8190
reload: False
reload_engine: auto
reload_extra_files: []
spew: False
check_config: False
print_config: False
preload_app: False
sendfile: None
reuse_port: False
chdir: /home/bit-web/pyvenv/project1
daemon: False
raw_env: []
pidfile: None
worker_tmp_dir: None
user: 0
group: 0
umask: 0
initgroups: False
tmp_upload_dir: None
secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
forwarded_allow_ips: ['127.0.0.1']
accesslog: None
disable_redirect_access_to_syslog: False
access_log_format: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
errorlog: error.log
loglevel: debug
capture_output: False
logger_class: gunicorn.glogging.Logger
logconfig: None
logconfig_dict: {}
syslog_addr: udp://localhost:514
syslog: False
syslog_prefix: None
syslog_facility: user
enable_stdio_inheritance: False
statsd_host: None
dogstatsd_tags:
statsd_prefix:
proc_name: None
default_proc_name: wsgi:application
pythonpath: None
paste: None
on_starting: <function OnStarting.on_starting at 0x7f7b0fa6eae8>
on_reload: <function OnReload.on_reload at 0x7f7b0fa6ebf8>
when_ready: <function WhenReady.when_ready at 0x7f7b0fa6ed08>
pre_fork: <function Prefork.pre_fork at 0x7f7b0fa6ee18>
post_fork: <function Postfork.post_fork at 0x7f7b0fa6ef28>
post_worker_init: <function PostWorkerInit.post_worker_init at 0x7f7b0fa860d0>
worker_int: <function WorkerInt.worker_int at 0x7f7b0fa861e0>
worker_abort: <function WorkerAbort.worker_abort at 0x7f7b0fa862f0>
pre_exec: <function PreExec.pre_exec at 0x7f7b0fa86400>
pre_request: <function PreRequest.pre_request at 0x7f7b0fa86510>
post_request: <function PostRequest.post_request at 0x7f7b0fa86598>
child_exit: <function ChildExit.child_exit at 0x7f7b0fa866a8>
worker_exit: <function WorkerExit.worker_exit at 0x7f7b0fa867b8>
nworkers_changed: <function NumWorkersChanged.nworkers_changed at 0x7f7b0fa868c8>
on_exit: <function OnExit.on_exit at 0x7f7b0fa869d8>
proxy_protocol: False
proxy_allow_ips: ['127.0.0.1']
keyfile: None
certfile: None
ssl_version: 2
cert_reqs: 0
ca_certs: None
suppress_ragged_eofs: True
do_handshake_on_connect: False
ciphers: None
raw_paste_global_conf: []
strip_header_spaces: False
[2022-12-01 15:28:04 -0700] [16349] [INFO] Starting gunicorn 20.1.0
[2022-12-01 15:28:04 -0700] [16349] [DEBUG] connection to ('project1.sock', 8000) failed: [Errno -2] Name or service not known
[2022-12-01 15:28:04 -0700] [16349] [ERROR] Retrying in 1 second.
[2022-12-01 15:28:05 -0700] [16349] [DEBUG] connection to ('project1.sock', 8000) failed: [Errno -2] Name or service not known
[2022-12-01 15:28:05 -0700] [16349] [ERROR] Retrying in 1 second.
[2022-12-01 15:28:06 -0700] [16349] [DEBUG] connection to ('project1.sock', 8000) failed: [Errno -2] Name or service not known
[2022-12-01 15:28:06 -0700] [16349] [ERROR] Retrying in 1 second.
[2022-12-01 15:28:07 -0700] [16349] [DEBUG] connection to ('project1.sock', 8000) failed: [Errno -2] Name or service not known
[2022-12-01 15:28:07 -0700] [16349] [ERROR] Retrying in 1 second.
[2022-12-01 15:28:08 -0700] [16349] [DEBUG] connection to ('project1.sock', 8000) failed: [Errno -2] Name or service not known
[2022-12-01 15:28:08 -0700] [16349] [ERROR] Retrying in 1 second.
[2022-12-01 15:28:09 -0700] [16349] [ERROR] Can't connect to ('project1.sock', 8000)
wsgi.py
from flask import Flask
application = Flask(__name__)
#application.route("/")
def hello():
return "<h1 style='color:blue'>Hello There!</h1>"
if __name__ == "__main__":
application.run(host='0.0.0.0')
the nginx.conf file that is being sourced from Puppet
(pyvenv) [root#guadalupe project1]# cat /etc/nginx/sites-enabled/project1.conf
include /etc/nginx/conf.d/*.conf;
upstream app_a {
server unix:///home/bit-web/pyvenv/project1/project1.sock;
}
server {
listen 80;
server_name guadalupe.int.colorado.edu, 172.20.13.55;
location / {
proxy_read_timeout 300;
proxy_connect_timeout 300;
include uwsgi_params;
uwsgi_pass app_a;
}
}
nginx error log
2022/12/01 15:02:15 [error] 11743#11743: *1 upstream prematurely closed connection while reading response header from upstream, client: 198.11.28.224, server: guadalupe.int.colorado.edu,, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:///home/bit-web/pyvenv/project1/project1.sock:", host: "guadalupe.int.colorado.edu", referrer: "http://guadalupe.int.colorado.edu/"
socket information
(pyvenv) [root#guadalupe project1]# ls
project1.sock __pycache__ wsgi.py
(pyvenv) [root#guadalupe project1]# pwd
/home/bit-web/pyvenv/project1
gunicorn service
(pyvenv) [root#guadalupe project1]# cat /etc/systemd/system/gunicorn.service
[Unit]
Description=Gunicorn instance to serve myproject
After=network.target
[Service]
User=bit-web
Group=nginx
WorkingDirectory=/home/bit-web/pyvenv/project1
Environment="PATH=/home/bit-web/pyvenv/bin"
ExecStart=/home/bit-web/pyvenv/bin/gunicorn --workers 3 --bind unix:project1.sock -m 007 wsgi:application
[Install]
WantedBy=multi-user.target
in your gunicorn service file, Instead of
ExecStart=/home/bit-web/pyvenv/bin/gunicorn --workers 3 --bind unix:project1.sock -m 007 wsgi:application
try this (means add .sock file path)
ExecStart=/home/bit-web/pyvenv/bin/gunicorn --workers 3 --bind unix:/home/bit-web/pyvenv/project1/project1.sock -m 007 wsgi:application
Here is my python code.
from aiohttp import web
if __name__ == "__main__":
app = web.Application()
cors = aiohttp_cors.setup(app)
app.on_shutdown.append(on_shutdown)
app.router.add_get("/", index)
app.router.add_get("/client.js", javascript)
cors = aiohttp_cors.setup(app, defaults={
"*": aiohttp_cors.ResourceOptions(
allow_credentials=True,
expose_headers="*",
allow_headers="*",
)
})
resource = cors.add(app.router.add_resource("/offer"))
cors.add(resource.add_route("POST", offer))
resource = cors.add(app.router.add_resource("/image_makeup"))
cors.add(resource.add_route("POST", image_makeup))
web.run_app(
app, access_log=None, host=args.host, port=args.port, ssl_context=ssl_context
)
Command:
gunicorn main:app --bind localhost:8080 --worker-class aiohttp.GunicornWebWorker
error:
[2020-10-17 21:17:13 +0530] [47676] [INFO] Starting gunicorn 20.0.4
[2020-10-17 21:17:13 +0530] [47676] [INFO] Listening at: http://127.0.0.1:8080 (47676)
[2020-10-17 21:17:13 +0530] [47676] [INFO] Using worker: sync
[2020-10-17 21:17:13 +0530] [47678] [INFO] Booting worker with pid: 47678
usage: gunicorn [-h] [--cert-file CERT_FILE] [--key-file KEY_FILE] [--host HOST] [--port PORT] [--verbose]
gunicorn: error: unrecognized arguments: --bind localhost:8080 wsgi:main
[2020-10-17 21:17:18 +0530] [47678] [INFO] Worker exiting (pid: 47678)
[2020-10-17 21:17:19 +0530] [47680] [INFO] Booting worker with pid: 47680
I have main.py inside my root directory still m getting above error.
Please have a look where i am making the mistake.
As you are not running directly your file "main.py", the value of the variable __name__ is not __main__ but main. You need to change your if statement :
if __name__ == "main":
app = web.Application()
...
As given in the documentation,
When running Gunicorn, you provide the name of the module, in your case main, and the name of the app or application factory, along with other Gunicorn Settings provided as command line flags or in your config file.
The entry point could be either an application instance or a coroutine that accepts no parameters and returns an application instance
Your Code has to be like:
from aiohttp import web
async def my_web_app():
app = web.Application()
....
return app
or
from aiohttp import web
my_web_app = web.Application()
....
Gunicorn command becomes:
gunicorn main:my_web_app --bind localhost:8080 --worker-class aiohttp.GunicornWebWorker
I made a little app with flask. I run the app on my ubuntu system as python3 app.py and everything works fine. I wanted to publish the app with gunicorn, but some functions also get errors. I looked at the error logs and [DEBUG] worker: SIGWINCH ignored. I get this error. The reason for the error is I put python pexpect module
def botbaslatma():
child = pexpect.spawn('screen -S idle python3 bot_dosyalari/{}'.format(session["username"]+".py"))
i=child.expect(['Enter 2FA code: ',"Invalid password for '{}'. Enter password: ".format(session["username"]),pexpect.EOF])
if i==0:
child.sendline(Guard)
k=child.expect(['Logged on as:','Incorrect code. Enter 2FA code: ',pexpect.EOF])
if k==0:
cursor=Mysql.connection.cursor()
sorgu='UPDATE sxxxxeri SET status="Aktif" WHERE stxxxxci="{}" '.format(session["username"])
cursor.execute(sorgu)
Mysql.connection.commit()
cursor.close()
child.close()
flash("Done","success")
return redirect(url_for("xontrolxxxx",_external=True))
elif k==1:
cursor=Mysql.connection.cursor()
sorgu='UPDATE sxxxleri SET status="Bexxxyor" WHERE steaxxxici="{}" '.format(session["username"])
cursor.execute(sorgu)
Mysql.connection.commit()
cursor.close()
child.close()
flash("Wrong passwd","danger")
return redirect(url_for("xontrolxxxx",_external=True))
elif i==2:#timeout
flash("Timeout","danger")
child.close()
durdurma()
return redirect(url_for("xontrolxxxx",_external=True))
elif i==1:
child.close()
durdurma()
flash("Wrong passwd","danger")
return redirect(url_for("xontrolxxxx",_external=True))
elif i==2:
child.close()
flash("Timeout","danger")
return redirect(url_for("xontrolxxxx",_external=True))
return render_template("botxxxx.html",form=form)
#Always enters pexpect.EOF control i==2
######Gunicorn3 file
[Unit]
Description=Gunicorn service
After=network.target
[Service]
User=root
Group=www-data
WorkingDirectory=/root/flaskapp
ExecStart=/usr/bin/gunicorn3 --workers 3 --bind unix:flaskapp.sock -m 007 app:app --timeout 300 --config /root/flaskapp/gunicorn.conf.py
#Gunicorn3 Error log *************
[2020-07-03 15:38:55 +0200] [14261] [DEBUG] Current configuration:
config: /root/flaskapp/gunicorn.conf.py
bind: ['unix:flaskapp.sock']
backlog: 2048
workers: 3
worker_class: sync
threads: 1
worker_connections: 1000
max_requests: 0
max_requests_jitter: 0
timeout: 300
graceful_timeout: 30
keepalive: 2
limit_request_line: 4094
limit_request_fields: 100
limit_request_field_size: 8190
reload: False
reload_engine: auto
spew: False
check_config: False
preload_app: False
sendfile: None
chdir: /root/flaskapp
daemon: False
raw_env: []
pidfile: None
worker_tmp_dir: None
user: 0
group: 33
umask: 7
initgroups: False
tmp_upload_dir: None
secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
forwarded_allow_ips: ['127.0.0.1']
accesslog: /root/flaskapp/flaskapp.gunicorn.access
access_log_format: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
errorlog: /root/flaskapp/flaskapp.gunicorn.error
loglevel: debug
capture_output: False
logger_class: gunicorn.glogging.Logger
logconfig: None
syslog_addr: udp://localhost:xxx
syslog: False
syslog_prefix: None
syslog_facility: user
enable_stdio_inheritance: False
statsd_host: None
statsd_prefix:
proc_name: None
default_proc_name: app:app
pythonpath: None
paste: None
on_starting: <function OnStarting.on_starting at 0x7f66cff9c048>
on_reload: <function OnReload.on_reload at 0x7f66cff9c1e0>
when_ready: <function WhenReady.when_ready at 0x7f66cff9c378>
pre_fork: <function Prefork.pre_fork at 0x7f66cff9c510>
post_fork: <function Postfork.post_fork at 0x7f66cff9c6a8>
post_worker_init: <function PostWorkerInit.post_worker_init at 0x7f66cff9c840>
worker_int: <function WorkerInt.worker_int at 0x7f66cff9c9d8>
worker_abort: <function WorkerAbort.worker_abort at 0x7f66cff9cb70>
pre_exec: <function PreExec.pre_exec at 0x7f66cff9cd08>
pre_request: <function PreRequest.pre_request at 0x7f66cff9cea0>
post_request: <function PostRequest.post_request at 0x7f66cff9f048>
child_exit: <function ChildExit.child_exit at 0x7f66cff9f1e0>
worker_exit: <function WorkerExit.worker_exit at 0x7f66cff9f378>
nworkers_changed: <function NumWorkersChanged.nworkers_changed at 0x7f66cff9f510>
on_exit: <function OnExit.on_exit at 0x7f66cff9f6a8>
proxy_protocol: False
proxy_allow_ips: ['127.0.0.1']
keyfile: None
certfile: None
ssl_version: 2
cert_reqs: 0
ca_certs: None
suppress_ragged_eofs: True
do_handshake_on_connect: False
ciphers: TLSv1
raw_paste_global_conf: []
[2020-07-03 15:38:55 +0200] [14261] [INFO] Starting gunicorn 19.7.1
[2020-07-03 15:38:55 +0200] [14261] [DEBUG] Arbiter booted
[2020-07-03 15:38:55 +0200] [14261] [INFO] Listening at: unix:flaskapp.sock (14261)
[2020-07-03 15:38:55 +0200] [14261] [INFO] Using worker: sync
[2020-07-03 15:38:55 +0200] [14282] [INFO] Booting worker with pid: 14282
[2020-07-03 15:38:55 +0200] [14285] [INFO] Booting worker with pid: 14285
[2020-07-03 15:38:55 +0200] [14286] [INFO] Booting worker with pid: 14286
[2020-07-03 15:38:55 +0200] [14261] [DEBUG] 3 workers
[2020-07-03 15:39:03 +0200] [14285] [DEBUG] GET /kontrolpaneli
[2020-07-03 15:39:03 +0200] [14285] [DEBUG] GET /login
[2020-07-03 15:39:13 +0200] [14282] [DEBUG] POST /login
[2020-07-03 15:39:13 +0200] [14285] [DEBUG] GET /
[2020-07-03 15:39:17 +0200] [14286] [DEBUG] GET /kontrolpaneli
[2020-07-03 15:39:19 +0200] [14285] [DEBUG] GET /botbaslatma
[2020-07-03 15:39:43 +0200] [14285] [DEBUG] POST /botbaslatma
[2020-07-03 15:39:43 +0200] [14412] [DEBUG] worker: SIGWINCH ignored. **here it is**
[2020-07-03 15:39:43 +0200] [14285] [DEBUG] GET /kontrolpaneli
This message is harmless. The signal SIGWINCH marks that the terminal window was resized. There is no real terminal under which your app runs, so that seems normal. It is probably produced by screen.
Your code is very weird. Rather than creating a terminal through screen and driving a python command line application through pexpect, the normal approach would be to call bot_dosyalari functions directly. However, it should work.
Additionally, you shouldn't be runnning a web application as root. I guess you did that because www-data didn't have access to /root/flaskapp, but the solution is to set the permissions right (probably moving it to e.g. /var/www/flaskapp at the same time), not to change the webapp user.
I've got an aiohttp web app that uses routes as flask like decorators and gunicorn
I'm having some trouble getting the logs to work correctly though.
What am I missing here?
No error's are being thrown or logged and the app run smoothly, but nothing is being logged apart from the start-up logs:
[2018-10-16 09:41:18 +0000] [1] [INFO] Starting gunicorn 19.9.0
[2018-10-16 09:41:18 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1)
[2018-10-16 09:41:18 +0000] [1] [INFO] Using worker: aiohttp.worker.GunicornWebWorker
[2018-10-16 09:41:18 +0000] [16] [INFO] Booting worker with pid: 16
[2018-10-16 09:41:18 +0000] [17] [INFO] Booting worker with pid: 17
[2018-10-16 09:41:18 +0000] [18] [INFO] Booting worker with pid: 18
[2018-10-16 09:41:18 +0000] [19] [INFO] Booting worker with pid: 19
[2018-10-16 09:41:18 +0000] [20] [INFO] Booting worker with pid: 20
[2018-10-16 09:41:18 +0000] [21] [INFO] Booting worker with pid: 21
[2018-10-16 09:41:18 +0000] [22] [INFO] Booting worker with pid: 22
[2018-10-16 09:41:18 +0000] [23] [INFO] Booting worker with pid: 23
My app/init.py file is as such:
import logging
import os
from logging import handlers
from aiohttp.web import Application
from app.routes import routes
from utils.logging import CloggerFormatter
def create_app(app_config):
app = Application()
logger = logging.getLogger('aiohttp.web')
log_level = logging.DEBUG
if os.environ.get('LOG_LEVEL'):
log_level = os.environ['LOG_LEVEL']
app.router.add_routes(routes)
logger.setLevel(log_level)
logger.addHandler(CloggerFormatter)
app['config'] = app_config
return app
And then in my app/routes.py file I access the logger with request.app.logger from within the rout definition like:
from aiohttp.web import Response, RouteTableDef
routes = RouteTableDef()
#routes.post('/background-checks')
async def api_background_check(request):
request_identifier = request.headers.get('X-Request-ID')
if not request_identifier:
request_identifier = uuid.uuid4()
request.app.logger.info('Checking background for request: %s', request_identifier)
This is my utils/handlers/logging.py file:
from time import strftime, gmtime
from logging import Formatter
class CloggerFormatter(Formatter):
"""
Logging module formatter in accordance with the yoti clogger manual
guidelines.
"""
converter = gmtime
def __init__(self, datefmt=None):
fmt = ('level:%(levelname)s'
'\ttime:%(asctime)s'
'\tmessage:%(message)s')
Formatter.__init__(self, fmt=fmt, datefmt=datefmt)
def formatTime(self, record, datefmt=None):
"""
Return the creation time of the LogRecord using the RFC 3339
format if datefmt is not specified.
"""
ct = self.converter(record.created)
if datefmt:
s = strftime(datefmt, ct)
else:
t = strftime('%Y-%m-%dT%H:%M:%S', ct)
s = '%s.%03dZ' % (t, record.msecs)
return s
Please use the root aiohttp logger: logger = logging.getLogger('aiohttp').
Particularly access logger uses 'aiohttp.access' name but maybe you want to see other log messages like errors and warnings as well.
I have a Flask app that runs fine locally. I pushed it to this Heroku URL:
https://secret-sierra-6425.herokuapp.com/
And the landing page works, which means the '/' route code works.
But when I try to access other resources, it throws a 500 error and I don't see anything useful in the logs:
2015-04-06T08:17:29.687713+00:00 app[web.1]: [2015-04-06 08:17:29 +0000] [3] [INFO] Shutting down: Master
2015-04-06T08:17:30.397309+00:00 app[web.1]: [2015-04-06 08:17:30 +0000] [3] [INFO] Starting gunicorn 19.3.0
2015-04-06T08:17:30.484520+00:00 app[web.1]: [2015-04-06 08:17:30 +0000] [10] [INFO] Booting worker with pid: 10
2015-04-06T08:17:30.398009+00:00 app[web.1]: [2015-04-06 08:17:30 +0000] [3] [INFO] Listening at: http://0.0.0.0:18230 (3)
2015-04-06T08:17:30.398107+00:00 app[web.1]: [2015-04-06 08:17:30 +0000] [3] [INFO] Using worker: sync
2015-04-06T08:17:30.407696+00:00 app[web.1]: [2015-04-06 08:17:30 +0000] [9] [INFO] Booting worker with pid: 9
2015-04-06T08:17:30.682319+00:00 heroku[web.1]: State changed from starting to up
2015-04-06T08:17:30.618107+00:00 heroku[web.1]: Process exited with status 0
2015-04-06T08:18:23.485060+00:00 heroku[router]: at=info method=GET path="/" host=secret-sierra-6425.herokuapp.com request_id=cbdfada9-8b28-4150-a7c0-eddc458658d9 fwd="23.252.53.59" dyno=web.1 connect=1ms service=2ms status=200 bytes=186
2015-04-06T08:18:35.630070+00:00 heroku[router]: at=info method=POST path="/messages" host=secret-sierra-6425.herokuapp.com request_id=aaecbfbd-57b5-49eb-aee0-ad450ba67e36 fwd="23.252.53.59" dyno=web.1 connect=1ms service=19ms status=500 bytes=456
This is the code to start my app:
if __name__ == '__main__':
app.debug = True #Only for development, not prod
app.logger.addHandler(logging.StreamHandler(sys.stdout))
app.logger.setLevel(logging.ERROR)
app.run()
Procfile:
web: gunicorn mailr:app --log-file=-
worker: python worker.py
My application uses redis queue as well. I've added the RedisToGo addon. Still no luck.
Can anyone help me find a way to display the logs so that I can debug what's going wrong?
\
EDIT:
Also tried changing the start to this, but still no luck:
app.debug = True #Only for development, not prod
file_handler = StreamHandler()
app.logger.setLevel(logging.DEBUG) # set the desired logging level here
app.logger.addHandler(file_handler)
app.run()
Got it. The code for logging should have been out of main