python - Capturing SIGTERM signal Heroku
问题描述
So i finally found how to capture the signal from this site "https://pymotw.com/2/signal/" , I now can capture most of the kill signals like SIGINT, SIGUSR1, SIGUSR2.... all except the SIGTERM which heroku uses for some reason when I get a SIGTERM my script just exit instead of capturing the signal and do some work, Can Anyone tell me if I'm doing something wrong? I'm testing with the command "kill -INT $pid", i can capture every kill signals Except the SIGTERM, THANKS....
Code :
run = false
def receive_signal(signum, stack):
print("Received:", signum)
global run
run = False
signal.signal(signal.SIGUSR1,receive_signal)
signal.signal(signal.SIGUSR2, receive_signal)
signal.signal(signal.SIGINT, receive_signal)
signal.signal(signal.SIGTERM, receive_signal)
print("My PID is:", os.getpid())
while run:
main()
解决方案
推荐阅读
- reactjs - package.json 依赖项中的打字稿
- android - 如何在我的屏幕指针中添加动画?
- java - 如何剪切 LocalDateTime 格式字符串以将年份从 4 位限制为 2 位?
- java - 错误的文件关联.java文件作为objectiveC
- laravel - 订阅者中的事件未触发
- javascript - 如何根据键在 React JS 中创建动态表?
- javascript - 如何使用 redux 增加简单的计数器和带有对象组件的计数器
- python - 在程序中调用的新 tkinter 窗口中的 Excetue 按钮(Python 3.x)
- javascript - 简单的初学者承诺链
- backup - 使用 helm chart 时如何创建 keycloak 备份