Skip to content

Instantly share code, notes, and snippets.

@tonghs
Last active September 7, 2021 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonghs/69534c0c70f7aa7a009acbccee0ea932 to your computer and use it in GitHub Desktop.
Save tonghs/69534c0c70f7aa7a009acbccee0ea932 to your computer and use it in GitHub Desktop.
#!/bin/bash
while [ 1 ]
do
gunicorn app:app --bind=$GUNICORN_BIND_ADDRESS --workers=$GUNICORN_WORKERS --log-level=$GUNICORN_LOG_LEVEL $GUNICORN_RELOAD --access-logfile=$GUNICORN_ACCESS_LOGFILE
echo ''
echo -e "\033[1;32m >>>>>> restart app, wait a moment... \033[0m"
sleep 3
done
version: '3.7'
services:
nginx:
image: nginx:latest
volumes:
- ./ci/nginx/conf.d/:/etc/nginx/conf.d/
- ./ci/nginx/nginx.conf:/etc/nginx/nginx.conf
- /var/log/:/var/log/
depends_on:
- web
ports:
- "8079:8080"
web:
build: .
image: tonghs/web-template
command: bash -c './dev.sh'
volumes:
- .:/opt/code
- /var/log/web-template/:/var/log/web-template/
environment:
- PYTHONPATH=/opt/code
- DEBUG=1
- GUNICORN_WORKERS=1
- GUNICORN_BIND_ADDRESS=0.0.0.0:5000
- GUNICORN_LOG_LEVEL=DEBUG
- GUNICORN_RELOAD=--reload
- GUNICORN_ACCESS_LOGFILE=-
- PYTHONUNBUFFERED=TRUE
- LOG_PATH=/var/log/web-template
# healthcheck:
# test: "curl -f http://localhost:5000/ping || exit 1"
# retries: 3
# interval: 1800s
# timeout: 30s
restart: always
nginx_1 | /docker-entrypoint.sh: Configuration complete; ready for start up
web_1 | [2021-09-03 12:26:16 +0800] [6] [INFO] Starting gunicorn 20.0.4
web_1 | [2021-09-03 12:26:16 +0800] [6] [DEBUG] Arbiter booted
web_1 | [2021-09-03 12:26:16 +0800] [6] [INFO] Listening at: http://0.0.0.0:5000 (6)
web_1 | [2021-09-03 12:26:16 +0800] [6] [INFO] Using worker: sync
web_1 | [2021-09-03 12:26:16 +0800] [9] [INFO] Booting worker with pid: 9
web_1 | [2021-09-03 12:26:16 +0800] [6] [DEBUG] 1 workers
web_1 | [2021-09-03 14:05:28 +0800] [9] [DEBUG] POST /tower/user/25/webhook
web_1 | 172.19.0.3 - - [03/Sep/2021:14:05:30 +0800] "POST /tower/user/25/webhook HTTP/1.0" 200 2 "-" "Tower-Hookshot"
web_1 | [2021-09-03 14:26:03 +0800] [9] [INFO] Worker exiting (pid: 9)
web_1 | [2021-09-03 14:26:03 +0800] [6] [INFO] Handling signal: term
Exception in thread Thread-6:
Traceback (most recent call last):
File "/home/tonghs/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/home/tonghs/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.6/http/client.py", line 1281, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1327, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1276, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1042, in _send_output
self.send(msg)
File "/usr/lib/python3.6/http/client.py", line 980, in send
self.connect()
File "/usr/local/lib/python3.6/dist-packages/docker/transport/unixconn.py", line 30, in connect
sock.connect(self.unix_socket)
FileNotFoundError: [Errno 2] No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/tonghs/.local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/home/tonghs/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/tonghs/.local/lib/python3.6/site-packages/urllib3/util/retry.py", line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/tonghs/.local/lib/python3.6/site-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/tonghs/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/home/tonghs/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.6/http/client.py", line 1281, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1327, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1276, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1042, in _send_output
self.send(msg)
File "/usr/lib/python3.6/http/client.py", line 980, in send
self.connect()
File "/usr/local/lib/python3.6/dist-packages/docker/transport/unixconn.py", line 30, in connect
sock.connect(self.unix_socket)
urllib3.exceptions.ProtocolError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.6/dist-packages/compose/cli/log_printer.py", line 168, in tail_container_logs
queue.put(QueueItem.new(presenter.color_func(wait_on_exit(container))))
File "/usr/local/lib/python3.6/dist-packages/compose/cli/log_printer.py", line 185, in wait_on_exit
exit_code = container.wait()
File "/usr/local/lib/python3.6/dist-packages/compose/container.py", line 268, in wait
return self.client.wait(self.id).get('StatusCode', 127)
File "/usr/local/lib/python3.6/dist-packages/docker/utils/decorators.py", line 19, in wrapped
return f(self, resource_id, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/docker/api/container.py", line 1303, in wait
res = self._post(url, timeout=timeout, params=params)
File "/usr/local/lib/python3.6/dist-packages/docker/utils/decorators.py", line 46, in inner
return f(self, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/docker/api/client.py", line 233, in _post
return self.post(url, **self._set_request_timeout(kwargs))
File "/home/tonghs/.local/lib/python3.6/site-packages/requests/sessions.py", line 581, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/home/tonghs/.local/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/home/tonghs/.local/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/home/tonghs/.local/lib/python3.6/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
Exception in thread Thread-5:
Traceback (most recent call last):
File "/home/tonghs/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/home/tonghs/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.6/http/client.py", line 1281, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1327, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1276, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1042, in _send_output
self.send(msg)
File "/usr/lib/python3.6/http/client.py", line 980, in send
self.connect()
File "/usr/local/lib/python3.6/dist-packages/docker/transport/unixconn.py", line 30, in connect
sock.connect(self.unix_socket)
FileNotFoundError: [Errno 2] No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/tonghs/.local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/home/tonghs/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/tonghs/.local/lib/python3.6/site-packages/urllib3/util/retry.py", line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/tonghs/.local/lib/python3.6/site-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/tonghs/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/home/tonghs/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.6/http/client.py", line 1281, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1327, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1276, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1042, in _send_output
self.send(msg)
File "/usr/lib/python3.6/http/client.py", line 980, in send
self.connect()
File "/usr/local/lib/python3.6/dist-packages/docker/transport/unixconn.py", line 30, in connect
sock.connect(self.unix_socket)
urllib3.exceptions.ProtocolError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.6/dist-packages/compose/cli/log_printer.py", line 168, in tail_container_logs
queue.put(QueueItem.new(presenter.color_func(wait_on_exit(container))))
File "/usr/local/lib/python3.6/dist-packages/compose/cli/log_printer.py", line 185, in wait_on_exit
exit_code = container.wait()
File "/usr/local/lib/python3.6/dist-packages/compose/container.py", line 268, in wait
return self.client.wait(self.id).get('StatusCode', 127)
File "/usr/local/lib/python3.6/dist-packages/docker/utils/decorators.py", line 19, in wrapped
return f(self, resource_id, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/docker/api/container.py", line 1303, in wait
res = self._post(url, timeout=timeout, params=params)
File "/usr/local/lib/python3.6/dist-packages/docker/utils/decorators.py", line 46, in inner
return f(self, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/docker/api/client.py", line 233, in _post
return self.post(url, **self._set_request_timeout(kwargs))
File "/home/tonghs/.local/lib/python3.6/site-packages/requests/sessions.py", line 581, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/home/tonghs/.local/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/home/tonghs/.local/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/home/tonghs/.local/lib/python3.6/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment