shutdown

ShutdownHook - 优雅地停止服务

强颜欢笑 提交于 2019-12-05 04:34:00
一什么是ShutdownHook Runtimejava中相关方法源码 ApplicationShutdownHooksjava 二java进程平滑退出的意义 三java进程平滑退出的思路 四如何屏敝第三方组件的ShutdownHook 五实现服务的平滑退出 1 Http请求 2 dubbo请求 3 RabbitMQ消费 4 Quartz任务 六为何重启时有时会有ClassNotFoundException 一、什么是ShutdownHook? 在Java程序中可以通过添加关闭钩子,实现在程序退出时关闭资源、平滑退出的功能。 使用Runtime.addShutdownHook(Thread hook)方法,可以注册一个JVM关闭的钩子,这个钩子可以在以下几种场景被调用: 1. 程序正常退出 2. 使用System.exit() 3. 终端使用Ctrl+C触发的中断 4. 系统关闭 5. 使用Kill pid命令干掉进程 Runtime.java中相关方法源码 public void addShutdownHook (Thread hook) { SecurityManager sm = System.getSecurityManager(); if (sm != null ) { sm.checkPermission( new RuntimePermission(

centos7重启及修改主机名

倾然丶 夕夏残阳落幕 提交于 2019-12-05 00:30:30
修改后重启centos7,然后关闭远程连接,重新打开连接进行登录 hostnamectl hostname 查看主机名 hostnamectl set-hostname pioneer1 修改主机名 reboot linux主要用于服务器领域,而在服务器上执行一项服务是永无止境的,除非遇到特殊情况,否则不会关机。和Windows不同,在linux系统下,很多进程是在后台执行的。在屏幕背后,可能有很多人同时在工作。如果直接按下电源的按钮,其他人的数据可能就此中断。更严重的是,若不正常关机,严重的话,可能会造成文件系统损坏,从而导致数据丢失。 如果要关机,必须保证当前系统中没有其他用户在登录系统。我们可以使用who命令查看是否还有其他人登录,或者使用命令ps -aux查看是否还有后台进程运行。shutdown,halt,poweroff都为关机的命令,我们可以使用命令man shutdown查看其帮助文档。例如,我们运行如下命令关机。 shutdown -h 10 #计算机将于10分钟后关闭,且会显示在登录用户的当前屏幕中 shutdown -h now #计算机会立刻关机 shutdown -h 22:22 #计算机会在这个时刻关机 shutdown -r now #计算机会立刻重启 shutdown -r +10 #计算机会将于10分钟后重启 reboot #重启 halt #关机

Jetty throws NoClassDefFoundError: org/eclipse/jetty/util/FutureCallback on shutdown

半世苍凉 提交于 2019-12-05 00:26:05
Our maven build throws at the end of the build of the shutdown of jetty a NoClassDefFoundError that I do not understand. Does anyone have an idea where this is comming from and how to fix it? Here is are the dependencies from the pom file: <dependencies> <dependency> <groupId>com.restfuse</groupId> <artifactId>com.eclipsesource.restfuse</artifactId> <version>1.0.0</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.4</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> <version>1

Reset a TCP socket connection from application

可紊 提交于 2019-12-04 21:20:17
How to reset an accept ed socket in application level either with IO::Socket::INET in perl or in C? There is a programm bind ing, listen ing on a TCP port, and accept s a client connection, after that it read s and write s some data. If I simply close or shutdown the socket, TCP layer gracefully terminates (with FIN packet), rather than, I'd generate an RST packet. You didn't specify the exact OS you are using. I found that Linux does have an API call which will reset a TCP connection, I have no idea how portable it is. The way to do it is to use the connect system call on the already

How (best) to post WM_QUIT to a running process?

痞子三分冷 提交于 2019-12-04 19:18:45
Goal: Shut down a running 32 bit GUI process under windows I have access to the executable pathname. There are potentially more than one copy of this software running, but only one started from a unique executable pathname. Because more than one instance of this executable can be running, a simple look at top level windows would need to distinguish between which executable pathname actually is responsible for that window... Possible Approaches: Enumerate processes & threads, then use PostThreadMessage(thread, WM_QUIT, 0, 0) This makes sense, but I'm worried about what technique to use to

linux关机流程

扶醉桌前 提交于 2019-12-04 19:11:14
将内存中的数据同步到硬盘 sync 语法 shutdown [OPTIONS...] [TIME] [WALL...] 【options】 -r, reboot Reboot the machine.(重新启动设备) -h Equivalent to poweroff(定时关机) 【time】 +m 表示从现在开始的制定分钟数 时间字符串可以是“hh:mm”格式的小时/分钟,指定在24小时内执行关机的时间格式 实例 shutdown -h now 立马关机 shutdown -h 23:15 系统会在今天的23:15关机 shutdown -h +10 系统会在10分钟后关机 shutdown -c 取消即将进行的关机 shutdown -r now 马上重启 等同于reboot shutdown -r +10 系统会在10分钟后重启 来源: https://www.cnblogs.com/longlogs/p/11879367.html

tomcat shutdown后,进程还存在的解决办法

最后都变了- 提交于 2019-12-04 18:40:08
基本原理为启动tomcat时记录启动tomcat的进程id(pid),关闭时强制杀死该进程 第一步 :vim修改tomcat下bin/catalina.sh文件,添加点东西,主要是记录tomcat的pid,如下: #设置记录CATALINA_PID。 #该设置会在启动时候bin下新建一个CATALINA_PID文件 #关闭时候从CATALINA_PID文件找到pid,kill。。。同时删除CATALINA_PID文件 在PRGDIR=`dirname "$PRG"`后面加上: if [ -z "$CATALINA_PID" ]; then CATALINA_PID=$PRGDIR/CATALINA_PID fi 第二步 vim tomcat的shutdown.sh文件,在最后一行加上-force: bin/shutdown.sh exec "$PRGDIR"/"$EXECUTABLE" stop -force "$@" #加上 -force 来源: oschina 链接: https://my.oschina.net/u/2897227/blog/1608132

The definitive code that prevents a c# console app from exiting [until custom cleanup code has completed]

為{幸葍}努か 提交于 2019-12-04 17:48:46
Can we work together to come up with something that works for control-c, control-break, log off, window X button pressed, etc? Here is what I have so far: class Program { private static ConsoleEventHandlerDelegate consoleHandler; delegate bool ConsoleEventHandlerDelegate(CtrlTypes eventCode); static void Main(string[] args) { consoleHandler = new ConsoleEventHandlerDelegate(ConsoleCtrlCheck); SetConsoleCtrlHandler(consoleHandler, true); System.Diagnostics.Process.GetCurrentProcess().Exited += delegate(object sender, EventArgs e) { GeneralManager.Stop(); }; Console.CancelKeyPress += delegate

gRPC: What is the recommended way to shut down an asynchronous server in C++?

放肆的年华 提交于 2019-12-04 16:45:28
问题 I have a gRPC server that hosts two asynchronous services ("Master" and "Worker"), and I would like to implement graceful shutdown for the server. Each service has its own grpc::CompletionQueue . There appear to be two Shutdown() methods that might be relevant: grpc::CompletionQueue::Shutdown() and grpc::Server::Shutdown(), but it's not clear from the documentation which ones should be used. What is a good pattern for shutting down an asynchronous service? 回答1: TL;DR: You must call both grpc:

2-1. 远程管理常用命令-关机和启动

谁说胖子不能爱 提交于 2019-12-04 15:10:49
01. 远程管理常用命令 目标 关机/重启 shutdown 查看或配置网卡信息 ifconfig ping 远程登录和复制文件 ssh scp 01. 关机/重启 序号 命令 对应英文 作用 01 shutdown 选项 时间 shutdown 关机/重新启动 1.1 shutdown shutdown命令可以 安全 关闭 或者重新启动系统 选项 含义 -r 重新启动 -c 取消关机计划,在一分钟内 提示: 不指定选项和参数 ,默认表示 1分钟 之后 关闭电脑 远程维护服务器时,最好不要关闭系统,而应该重启系统 常用命令示例 1#现在关机重启 $ shutdown -r now 2#立刻关机 $ shutdown now 3#在系统今天20:15关机 $ shutdown 20:15 $ shutdown +10 来源: https://www.cnblogs.com/AI-robort/p/11870768.html