open-data / og-cli

Open Government Command Line Interface
Other
0 stars 0 forks source link

ckan werkzeug debug mode? #2

Open wardi opened 2 years ago

wardi commented 2 years ago

I'd like to use ckan run (or paster serve on 2.8) instead of uwsgi so that I get automatic reloading when I change source/templates. What's the best way to add this?

JVickery-TBS commented 2 years ago

@wardi You can edit the supervisord config file for ckan: https://github.com/open-data/docker-og/blob/master/docker/config/supervisor/conf.d/ckan-registry.conf (located docker/config/supervisor/conf.d in your project dir).

You can change the command there to the ckan run or paster server

OR you could try adding --py-autoreload=1 as an option to the existing wsgi command.

You will have to restart the ckan container afterwards.

JVickery-TBS commented 2 years ago

Autoreloading for python files and templates works now with these commits:

--py-autoreload seemed to solve jinja template reloading. And --emperor will reload the uwsgi application if there are any changes to the py scripts in the given source directories /srv/app/ckan/portal/src | /srv/app/ckan/registry/src. Note, that it will NOT auto reload for the other python libraries located in /srv/app/ckan/portal/lib | /srv/app/ckan/registry/lib. So if you install a new library or update/remove one, you will need to do a docker-compose restart ckan

JVickery-TBS commented 2 years ago

For dev/debug tools, @wardi suggest that ckan run (2.9) or paster serve (2.8) would be better. So I will try to replace the uwsgi command in the supervisord configs with the ckan run | paster serve

wardi commented 2 years ago

The original problem was that pylons controller errors aren't caught by the new flask werkzeug stuff properly. I switched back to 04ef1f6ea79 before the ckan2.9/* branches and the debugger is working fine in flask views.

I did try branch ckan2.9/uwsgi but that failed to start with an unrelated error, so I assume that's a work-in-progress too.

One minor thing that is more convenient in the ckan run version is that a debugger pin code isn't required, but this isn't a big deal. I'll use uwsgi for a while and see if there are any other issues or if we can close this ticket

JVickery-TBS commented 2 years ago

@wardi The ckan2.9/uwsgi branch should work (what is the error?)

Regarding the debugger pin, I was able to turn that off with an environment variable WERKZEUG_DEBUG_PIN=off (set in the docker-compose.yml file), so that should hopefully not be a problem.