mirror of
				https://github.com/cookiecutter/cookiecutter-django.git
				synced 2025-10-31 16:07:49 +03:00 
			
		
		
		
	Added Heroku and Gulp support
* Deleted some unnecessary info inside asgi.py
This commit is contained in:
		
							parent
							
								
									041751a359
								
							
						
					
					
						commit
						f0813a24b2
					
				|  | @ -1,5 +1,9 @@ | ||||||
| release: python manage.py migrate | release: python manage.py migrate | ||||||
|  | {% if cookiecutter.use_async == "y" -%} | ||||||
|  | web: gunicorn config.asgi:application -k uvicorn.workers.UvicornWorker | ||||||
|  | {%- else  %} | ||||||
| web: gunicorn config.wsgi:application | web: gunicorn config.wsgi:application | ||||||
|  | {%- endif %} | ||||||
| {% if cookiecutter.use_celery == "y" -%} | {% if cookiecutter.use_celery == "y" -%} | ||||||
| worker: celery worker --app=config.celery_app --loglevel=info | worker: celery worker --app=config.celery_app --loglevel=info | ||||||
| beat: celery beat --app=config.celery_app --loglevel=info | beat: celery beat --app=config.celery_app --loglevel=info | ||||||
|  |  | ||||||
|  | @ -7,7 +7,6 @@ For more information on this file, see | ||||||
| https://docs.djangoproject.com/en/dev/howto/deployment/asgi/ | https://docs.djangoproject.com/en/dev/howto/deployment/asgi/ | ||||||
| 
 | 
 | ||||||
| """ | """ | ||||||
| import os |  | ||||||
| import sys | import sys | ||||||
| from pathlib import Path | from pathlib import Path | ||||||
| 
 | 
 | ||||||
|  | @ -17,22 +16,15 @@ from django.core.asgi import get_asgi_application | ||||||
| # {{ cookiecutter.project_slug }} directory. | # {{ cookiecutter.project_slug }} directory. | ||||||
| app_path = Path(__file__).parents[1].resolve() | app_path = Path(__file__).parents[1].resolve() | ||||||
| sys.path.append(str(app_path / "{{ cookiecutter.project_slug }}")) | sys.path.append(str(app_path / "{{ cookiecutter.project_slug }}")) | ||||||
| # We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks |  | ||||||
| # if running multiple sites in the same mod_wsgi process. To fix this, use |  | ||||||
| # mod_wsgi daemon mode with each site in its own daemon process, or use |  | ||||||
| # os.environ["DJANGO_SETTINGS_MODULE"] = "config.settings.production" |  | ||||||
| os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production") |  | ||||||
| 
 | 
 | ||||||
| # This application object is used by any ASGI server configured to use this | # This application object is used by any ASGI server configured to use this file. | ||||||
| # file. This includes Django's development server, if the ASGI_APPLICATION |  | ||||||
| # setting points here. |  | ||||||
| django_application = get_asgi_application() | django_application = get_asgi_application() | ||||||
| # Apply ASGI middleware here. | # Apply ASGI middleware here. | ||||||
| # from helloworld.asgi import HelloWorldApplication | # from helloworld.asgi import HelloWorldApplication | ||||||
| # application = HelloWorldApplication(application) | # application = HelloWorldApplication(application) | ||||||
| 
 | 
 | ||||||
| # Import websocket application here, so apps from django_application are loaded first | # Import websocket application here, so apps from django_application are loaded first | ||||||
| from .websocket import websocket_application  # noqa isort:skip | from config.websocket import websocket_application  # noqa isort:skip | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| async def application(scope, receive, send): | async def application(scope, receive, send): | ||||||
|  |  | ||||||
|  | @ -110,6 +110,18 @@ function imgCompression() { | ||||||
|     .pipe(dest(paths.images)) |     .pipe(dest(paths.images)) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | {% if cookiecutter.use_async == 'y' -%} | ||||||
|  | // Run django server
 | ||||||
|  | function asyncRunServer(cb) { | ||||||
|  |   var cmd = spawn('gunicorn', [ | ||||||
|  |       'config.asgi', '-k', 'uvicorn.workers.UvicornWorker', '--reload' | ||||||
|  |       ], {stdio: 'inherit'} | ||||||
|  |   ) | ||||||
|  |   cmd.on('close', function(code) { | ||||||
|  |     console.log('gunicorn exited with code ' + code) | ||||||
|  |   }) | ||||||
|  | } | ||||||
|  | {%- else %} | ||||||
| // Run django server
 | // Run django server
 | ||||||
| function runServer(cb) { | function runServer(cb) { | ||||||
|   var cmd = spawn('python', ['manage.py', 'runserver'], {stdio: 'inherit'}) |   var cmd = spawn('python', ['manage.py', 'runserver'], {stdio: 'inherit'}) | ||||||
|  | @ -118,6 +130,7 @@ function runServer(cb) { | ||||||
|     cb(code) |     cb(code) | ||||||
|   }) |   }) | ||||||
| } | } | ||||||
|  | {%- endif %} | ||||||
| 
 | 
 | ||||||
| // Browser sync server for live reload
 | // Browser sync server for live reload
 | ||||||
| function initBrowserSync() { | function initBrowserSync() { | ||||||
|  | @ -166,8 +179,12 @@ const generateAssets = parallel( | ||||||
| // Set up dev environment
 | // Set up dev environment
 | ||||||
| const dev = parallel( | const dev = parallel( | ||||||
|   {%- if cookiecutter.use_docker == 'n' %} |   {%- if cookiecutter.use_docker == 'n' %} | ||||||
|  |   {%- if cookiecutter.use_async == 'y' %} | ||||||
|  |   asyncRunServer, | ||||||
|  |   {%- else %} | ||||||
|   runServer, |   runServer, | ||||||
|   {%- endif %} |   {%- endif %} | ||||||
|  |   {%- endif %} | ||||||
|   initBrowserSync, |   initBrowserSync, | ||||||
|   watchPaths |   watchPaths | ||||||
| ) | ) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user