mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	Fix for gunicorn command (#7450)
* Fix for gunicorn command * Allow override of worker count
This commit is contained in:
		
							
								
								
									
										29
									
								
								tasks.py
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								tasks.py
									
									
									
									
									
								
							| @@ -777,18 +777,31 @@ def wait(c): | |||||||
|     return manage(c, 'wait_for_db') |     return manage(c, 'wait_for_db') | ||||||
|  |  | ||||||
|  |  | ||||||
| @task(pre=[wait], help={'address': 'Server address:port (default=0.0.0.0:8000)'}) | @task( | ||||||
| def gunicorn(c, address='0.0.0.0:8000'): |     pre=[wait], | ||||||
|  |     help={ | ||||||
|  |         'address': 'Server address:port (default=0.0.0.0:8000)', | ||||||
|  |         'workers': 'Specify number of worker threads (override config file)', | ||||||
|  |     }, | ||||||
|  | ) | ||||||
|  | def gunicorn(c, address='0.0.0.0:8000', workers=None): | ||||||
|     """Launch a gunicorn webserver. |     """Launch a gunicorn webserver. | ||||||
|  |  | ||||||
|     Note: This server will not auto-reload in response to code changes. |     Note: This server will not auto-reload in response to code changes. | ||||||
|     """ |     """ | ||||||
|     c.run( |     here = os.path.dirname(os.path.abspath(__file__)) | ||||||
|         'gunicorn -c ./docker/gunicorn.conf.py InvenTree.wsgi -b {address} --chdir ./InvenTree'.format( |     config_file = os.path.join(here, 'contrib', 'container', 'gunicorn.conf.py') | ||||||
|             address=address |     chdir = os.path.join(here, 'src', 'backend', 'InvenTree') | ||||||
|         ), |  | ||||||
|         pty=True, |     cmd = f'gunicorn -c {config_file} InvenTree.wsgi -b {address} --chdir {chdir}' | ||||||
|     ) |  | ||||||
|  |     if workers: | ||||||
|  |         cmd += f' --workers={workers}' | ||||||
|  |  | ||||||
|  |     print('Starting Gunicorn Server:') | ||||||
|  |     print(cmd) | ||||||
|  |  | ||||||
|  |     c.run(cmd, pty=True) | ||||||
|  |  | ||||||
|  |  | ||||||
| @task(pre=[wait], help={'address': 'Server address:port (default=127.0.0.1:8000)'}) | @task(pre=[wait], help={'address': 'Server address:port (default=127.0.0.1:8000)'}) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user