shutdown

In PHP does max_execution_time affect shutdown functions that are run through a register_shutdown_function() call?

时光总嘲笑我的痴心妄想 提交于 2019-12-10 14:49:40
问题 I have a shutdown function registered using register_shutdown_function() that takes a long time to complete. Will PHP's max_execution_time cause PHP to terminate this function or will it run until it completes or errors out? 回答1: It will run to completion. http://us2.php.net/manual/en/function.register-shutdown-function.php#33575 来源: https://stackoverflow.com/questions/4620517/in-php-does-max-execution-time-affect-shutdown-functions-that-are-run-through-a

How do I gracefully shutdown the Tokio runtime in response to a SIGTERM?

青春壹個敷衍的年華 提交于 2019-12-10 14:40:06
问题 I have a main function, where I create a Tokio runtime and run two futures on it. use tokio; fn main() { let mut runtime = tokio::runtime::Runtime::new().unwrap(); runtime.spawn(MyMegaFutureNumberOne {}); runtime.spawn(MyMegaFutureNumberTwo {}); // Some code to 'join' them after receiving an OS signal } How do I receive a SIGTERM , wait for all unfinished tasks ( NotReady s) and exit the application? 回答1: Dealing with signals is tricky and it would be too broad to explain how to handle all

PHP shutdown: Can't write files?

旧街凉风 提交于 2019-12-10 14:19:55
问题 I'm using a Log class to store messages during execution, and then it is supposed to write these messages to a file on shutdown (with register_shutdown_function). But for some reason, I'm always getting "file_put_contents failed to open stream: No such file or directory". It shouldn't be a problem that the file doesn't exist, file_put_contents should create the file. In fact, everything works just fine if I do the write during execution (ie: before the shutdown function is called). Is this a

Delphi prevent application shutdown

社会主义新天地 提交于 2019-12-10 13:42:41
问题 I am trying to prevent my application from being shutdown by windows. The application is running on windows 8 and written in XE6. I tried following code but it seems to be completely ignored. To test it I simply send "end task" to it through the task manager. What I need is a way to let my application finish what its doing when the application is closed by the user, by the task manager of by a windows shutdown. Normal closing is not a problem, this is handled by the FormCloseQuery event. But

Running a Shell Script on Shutdown via launchd

為{幸葍}努か 提交于 2019-12-10 10:39:21
问题 Since startup items and rc commands are both deprecated (and in many cases not working at all) on OS X in favour of launchd , I'd like to find out what the correct way would be to setup a shell script that runs on logout/shutdown. For a startup item it was possible to create a shell script that looked something like: #!/bin/sh StartService() { echo "Started." } StopService() { echo "Stopped." } RunService "$1" But the RunService command isn't supported when running a script from launchd , and

如何优雅关闭 Spring Boot 应用

不打扰是莪最后的温柔 提交于 2019-12-10 09:14:59
前言   随着线上应用逐步采用 SpringBoot 构建,SpringBoot应用实例越来多,当线上某个应用需要升级部署时,常常简单粗暴地使用 kill 命令,这种停止应用的方式会让应用将所有处理中的请求丢弃,响应失败。这样的响应失败尤其是在处理重要业务逻辑时需要极力避免的,那么有什么更好的方式来平滑地关闭 SpringBoot 应用呢?那就通过本文一起来探究吧。(本文主要针对基于Spring Boot 内嵌 Tomcat 容器作为 Web 服务的应用) 定制 Tomcat Connector 行为   要平滑关闭 Spring Boot 应用的前提就是首先要关闭其内置的 Web 容器,不再处理外部新进入的请求。为了能让应用接受关闭事件通知的时候,保证当前 Tomcat 处理所有已经进入的请求,我们需要实现 TomcatConnectorCustomizer 接口,这个接口的源码十分简单,从注释可以看出这是实现自定义 Tomcat Connector 行为的回调接口:     这里如果小伙伴对 Connector 不太熟悉,我就简单描述下:Connector 属于 Tomcat 抽象组件,功能就是用来接受外部请求,以及内部传递,并返回响应内容,是Tomcat 中请求处理和响应的重要组件,具体实现有 HTTP Connector 和 AJP Connector。     通过定制

In python, how to get a UDPServer to shutdown itself?

会有一股神秘感。 提交于 2019-12-10 08:46:00
问题 I've created a class for a server with the declaration: class myServer(socketserver.BaseRequestHandler): def handle(self): pass And started it with: someServer = socketserver.UDPServer((HOST, PORT), myServer) someServer.serve_forever() My question is: how can I get the server to shutdown itself? I've seen it has a base class (of a base class) called BaseServer with a shutdown method. It can be called on someServer with someServer.shutdown() but this is from the outside of the server itself.

如何实现ubuntu每天定时关机

一个人想着一个人 提交于 2019-12-10 07:12:50
编辑 /etc/crontab添加一条 并且保证crontab服务的运行即可 f1 f2 f3 f4 f5 sudo /sbin/halt 假设 要每天的23点30定时关机 命令如下 30 23 * * * sudo /sbin/halt 至于crontab 服务 再GUI下的服务管理中设置为自动启动即可 其中 f1 是表示分钟,f2 表示小时,f3 表示一个月份中的第几日,f4 表示月份,f5 表示一个星期中的第几天。program 表示要执行的程式。 当 f1 为 * 时表示每分钟都要执行 program,f2 为 * 时表示每小时都要执行程式,其余类推 当 f1 为 a-b 时表示从第 a 分钟到第 b 分钟这段时间内要执行,f2 为 a-b 时表示从第 a 到第 b 小时都要执行,其余类推 当 f1 为 */n 时表示每 n 分钟个时间间隔执行一次,f2 为 */n 表示每 n 小时个时间间隔执行一次,其余类推 当 f1 为 a, b, c,... 时表示第 a, b, c,... 分钟要执行,f2 为 a, b, c,... 时表示第 a, b, c...个小时要执行,其余类推 如何设置ubuntu系统定时关机? 1. apt-get install sysv-rc-conf 2. sysv-rc-conf 3. 打开crontab服务 5. 编辑/etc/crontab

Oracle Data Guard 的角色转换(Switchover)

风流意气都作罢 提交于 2019-12-09 21:24:20
Oracle Data Guard 的角色转换( Switchover ) [日期:2013-06-18] 来源:Linux社区 作者:newhappy [字体:大 中 小] 实验环境:OEL+ Oracle 11.2.0.3+physical standby 众所周知,Data Guard已经是现今标准的主流容灾方案,由于日志传递对于网络适应程度强,且可以采用同步实时的传递方式和异步延迟的传递方式,甚至可以成为远程的异地容灾方案。不管用于何种用途,DG都免不了要进行角色转换,即将standby 数据库切换为primary数据库,角色转换分为:switchover和failover两种;两种区别从三个角度来对比: (1)、使用场合不同:Switchover 用于有准备的、计划之中的切换,通常是系统升级、数据迁移等常态任务;Failover用于意料之外的突发情况,比如异常掉电、自然灾难等等。 (2)、数据丢失程度不同:Switchover不会丢失数据,Failover通常意味着有部分数据丢失。 (3)、善后处理的不同:Switchover之后Dataguard环境不会被破坏,任然有Primary、Standby两种角色的系统存在。但是Failover之后,Dataguard环境就会被破坏,必须需要重建。 一、Switchover 因为Switchover这种转化是有DBA主动

Android root poweroff

拜拜、爱过 提交于 2019-12-09 17:04:53
问题 On my android app for root user, I perform a shutdown with su reboot -p It works ok, but I noticed that the phone is shutdown almost instantly (as opposed from showing the shutdown animation, and probably doing other stuff). Is this the correct way to shutdown an android phone programmatically? Are there some critical code that requires to be executed before shutdown? 回答1: In the Android source code, you can find the following: /** * Low-level function turn the device off immediately, without