Sanic in AWS ECS raise error on start

Hi guys, would like to ask your help regarding to deploy microservices application in AWS ECS with docker compose.

After my infrastructure are starting to deploy and Sanic server is starting I’m facing this error

timestamp	message				
1670151438012	[2022-12-04 10:57:18 +0000] [1] [DEBUG] 				
1670151438012	                 Sanic				
1670151438012	         Build Fast. Run Fast.				
1670151438012	[2022-12-04 10:57:18 +0000] [1] [INFO] Sanic v22.9.1				
1670151438012	[2022-12-04 10:57:18 +0000] [1] [INFO] Goin' Fast @ http://0.0.0.0:8000				
1670151438012	[2022-12-04 10:57:18 +0000] [1] [INFO] mode: debug, single worker				
1670151438012	[2022-12-04 10:57:18 +0000] [1] [INFO] server: sanic, HTTP/1.1				
1670151438013	[2022-12-04 10:57:18 +0000] [1] [INFO] python: 3.10.8				
1670151438013	[2022-12-04 10:57:18 +0000] [1] [INFO] platform: Linux-4.14.294-220.533.amzn2.x86_64-x86_64-with-glibc2.28				
1670151438013	[2022-12-04 10:57:18 +0000] [1] [INFO] auto-reload: enabled				
1670151438013	[2022-12-04 10:57:18 +0000] [1] [INFO] packages: sanic-routing==22.8.0, sanic-ext==22.9.1				
1670151438209	[2022-12-04 10:57:18 +0000] [1] [DEBUG] e[34mStarting a process: e[1me[38	2	255	13	104mSanic-Server-0-0e[0m
1670151438225	[2022-12-04 10:57:18 +0000] [1] [DEBUG] e[34mStarting a process: e[1me[38	2	255	13	104mSanic-Reloader-0e[0m
1670151443715	[2022-12-04 10:57:23 +0000] [1] [ERROR] Not all workers are ack. Shutting down.				
1670151443715	[2022-12-04 10:57:23 +0000] [1] [ERROR] Experienced exception while trying to serve				
1670151443715	Traceback (most recent call last):				
1670151443715	  File "/usr/local/lib/python3.10/site-packages/sanic/mixins/startup.py", line 851, in serve				
1670151443715	    manager.run()				
1670151443715	  File "/usr/local/lib/python3.10/site-packages/sanic/worker/manager.py", line 63, in run				
1670151443715	    self.monitor()				
1670151443715	  File "/usr/local/lib/python3.10/site-packages/sanic/worker/manager.py", line 99, in monitor				
1670151443715	    self.wait_for_ack()				
1670151443715	  File "/usr/local/lib/python3.10/site-packages/sanic/worker/manager.py", line 139, in wait_for_ack				
1670151443715	    sys.exit(1)				
1670151443715	SystemExit: 1				
1670151443715	[2022-12-04 10:57:23 +0000] [1] [INFO] Server Stopped				

If someone faced it already or know how to fix it, I would be grateful

Thanks in advance!

It might be that your app is taking a long time to startup. By a “long time” I mean more than 5s which is the default length for startup in v22.9. There is some change planned for this in v22.12 that will make this easier and more tolerant.

One workaround you might try is to monkeypatch the timeout. Add this as early in your application script as you can in the global scope:

from sanic.worker.manager import WorkerManager

WorkerManager.THRESHOLD = 100  # in increments of 0.1s, so this would be 10s
1 Like

Thanks for fast reply, it’s helped