小编etl*_*lsh的帖子

uwsgi master 优雅关机

我正在运行 uwsgi+flask 应用程序,该应用程序作为 k8s pod 运行。

当我部署一个新的 pod(一个新版本)时,现有的 pod 会收到 SIGTERM。

这将导致主停止接受新的连接在同一时刻,是什么原因导致问题的LB仍请求传递给吊舱(几秒钟)。

我希望主人在停止接受新连接之前等待 30 秒(当获得 SIGTERM 时)但找不到方法,这可能吗?

我的 uwsgi.ini 文件:[uwsgi]

;https://uwsgi-docs.readthedocs.io/en/latest/HTTP.html
http = :8080
wsgi-file = main.py
callable = wsgi_application
processes = 2
enable-threads = true
master = true
reload-mercy = 30
worker-reload-mercy = 30
log-5xx = true
log-4xx = true
disable-logging = true
stats = 127.0.0.1:1717
stats-http = true
single-interpreter= true
;https://github.com/containous/traefik/issues/615
http-keepalive=true
add-header = Connection: Keep-Alive
Run Code Online (Sandbox Code Playgroud)

python uwsgi kubernetes

7
推荐指数
1
解决办法
2292
查看次数

使用 GitPython 签出新分支并推送到远程

给定repo来自 GitPython 的 a,我如何创建一个新的本地分支,添加一些文件,并使用 GitPython 将其推送到远程?

创建一个repo

from git import *

curr_dir = os.path.dirname(os.path.realpath(__file__))
repo = Repo(curr_dir)
Run Code Online (Sandbox Code Playgroud)

现在,我只是使用subprocess

def publish_changes_to_git(commit_msg):
    curr_time = time.time()
    ts = datetime.datetime.fromtimestamp(curr_time).strftime('%Y-%m-%d-%H-%M-%S')
    branch_name = "auto-commit-{ts}".format(ts=ts)
    subprocess.check_output(["git", "checkout", "-b", branch_name])
    subprocess.check_output(["git", "add", SOME_PATH])
    subprocess.check_output(
        ["git", "commit", "-m", "auto-git-commit: {msg}".format(msg=commit_msg)])
Run Code Online (Sandbox Code Playgroud)

python git gitpython

6
推荐指数
2
解决办法
9455
查看次数

标签 统计

python ×2

git ×1

gitpython ×1

kubernetes ×1

uwsgi ×1