shutdown

Linux kill & Java shutdownhook

蹲街弑〆低调 提交于 2019-12-20 01:09:21
landon30 关注 2018.08.27 18:47:39字数 1,602阅读 677 shutdown-hook 建议加上shutdown的钩子 如果程序出现了内存溢出crash 则现在代码是没有任何保护措施的 或者说运维不小心关闭了服务器等 或者运维不小心kill了游戏服务器进程等 无法避免kill -9 时机 程序正常退出 使用System.exit() 终端使用Ctrl+C触发的中断 + 系统关闭 OutOfMemory宕机 使用Kill pid命令干掉进程(注:在使用kill -9 pid时,是不会被调用的) kill kill默认信号是SIGTERM 15 终止信号 kill -9 SIGKILL kill信号 kill -2 SIGINT interrupt 中断信号 同ctrl-c kill -1 SIGHUP hang up 挂起信号 kill -3 SIGQUIT 可打印进程#线程堆栈 只有kill -9能够结束jvm进程,别的信号量只是发送给java进程处理,至于如何响应是程序代码决定的 SIGTERM是不带参数时kill发送的信号,意思是进程终止运行,但执行与否还得看进程是否支持.如果进程还没有终止,可以使用 kill -SIGKILL pid,这是由内核来终止进程,进程不能监听这个信号 Java程序如果添加了shutdownhook,则可以监听1/2

linux虚拟机关机、重启命令

怎甘沉沦 提交于 2019-12-20 00:05:59
linux虚拟机关机、重启命令 一.shutdown 1.shutdown -h now :立即关机 2.shutdown -h 10:53:到10:53关机 3.shutdown -h +10 :10分钟后自动关机 4.shutdown -r :重启(默认30秒) 5.shutdown -r now :立即重启 6.shutdown -r +30 :’The System Will Reboot 30 in Mins’:30分钟后重启并发送通知给其他在线用户 7.shutdown -s -t 100 :延迟100秒关机 8.shutdown -a :取消上面的关机、重启 二、reboot 1.reboor :重启,相当于shutdown -r now 2.reboot -d :重新启动时不把数据写入记录文件 /var/tmp/wtmp 3.reboot -f :强制重新开机 4.reboot -h:在系统关机之前,将所有的硬盘处于待机模式下 5.reboot -i :关闭网络设置之后再重新启动系统 6.reboot -n :保存数据后重启 三、halt 1.halt : 关机 2.halt -d :关闭系统,不把记录写到/var/log/wtmp文件里 3.halt -p :关机并关闭电源 4.halt -f :强制关机 四、init 1.init 0 :关机 2.0-6

Why is my 'shutdown callback ' invalid when using register_shutdown_function()?

蓝咒 提交于 2019-12-19 08:10:13
问题 Warning: register_shutdown_function(): Invalid shutdown callback trait ErrorTrait { public function shutDownFunction() { $error = error_get_last(); // fatal error, E_ERROR === 1 if ($error['type'] === E_ERROR) { //do your stuff $messageStore="Using $this when not in object context"; if (strstr ( $error['message'],$messageStore)) { echo "found it"; } } } public function shutdown_function() { register_shutdown_function('shutDownFunction'); } } I use this trait in my main class and call the

Jetty: Stopping programatically causes “1 threads could not be stopped”

╄→гoц情女王★ 提交于 2019-12-19 06:56:31
问题 I have an embedded Jetty 6.1.26 instance. I want to shut it down by HTTP GET sent to /shutdown . So I created a JettyShutdownServlet : @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setStatus(202, "Shutting down."); resp.setContentType("text/plain"); ServletOutputStream os = resp.getOutputStream(); os.println("Shutting down."); os.close(); resp.flushBuffer(); // Stop the server. try { log.info("Shutting down the

给树莓派添加开关机键

僤鯓⒐⒋嵵緔 提交于 2019-12-19 03:30:14
声明 本文由u013062709原创,禁止二次修改发布。转载及引用内容请注明出处,并标明本站网址。文中程序仅供学习使用,本人不承担任何由使用文中代码产生的法律责任。 给树莓派添加开、关机键 作为一个硬件爱好者、嵌入式系统工程师、技术宅,树莓派肯定是要玩一玩的,但是用的时间长了总会发现它有一些不完美的地方,比如:没有电源键! 常用的关机方法有两种(外接屏幕和键盘的就不说了): 1. 远程登录然后敲命令(这是最合适的关机方法,但是太麻烦,如果没有电脑在身边就没法关机了) 2. 拔电源(简单粗暴,但很容易导致文件损坏) 所以为了愉快的使用树莓派,最好还是给它添加一个像电脑一样的电源键,百度了一大圈发现国内(没错,我就是针对国内,来来回回就那么几篇文章,还反反复复互相抄)只有一种添加电源键的方法,那就是写个python脚本、或者其他脚本、或者编译一个程序,反正原理都是一样的,让这个脚本(或程序)开机启动,程序中一直检测设置为电源键的GPIO,如果被触发则关机。这个方法虽然能解决问题,但真的low爆了!!!而且只能关机,不能开机。 在这里跟大家分享一个非常优雅,能关机也能开机的方法: 其实 /boot/overlays/README 里面已经说的很详细了,为了造福广大人民群众,我就整理一下。 不少人看见英文就头疼,而且这个文件有上千行,很少有人会仔细阅读,这里我就只把电源相关的内容摘录出来

Tomcat 端口配置文件端口说明

北慕城南 提交于 2019-12-18 12:49:52
以Tomcat7.0为例, 在安装目录下. conf/server.xml 中可以配置三个端口号, 如果使用多个tomcat 是需要配置这三个。 该 Connector 用于监听浏览器发送的请求。 设置成80 后可以直接使用http://localhost 访问。 tomcat 监听的关闭端口(多tomcat部署时一定要改成不同,否则关闭的时候会找这个端口关闭)。 <Server port="8005" shutdown="SHUTDOWN"> port指定Tomcat监听shutdown命令端口。终止服务器运行时,必须在Tomcat服务器所在的机器上发出shutdown命令,8005端口收到命令后执行关闭。 (不用8080端口接收关闭命令保证了tomcat的可控性) protocol: http协议 connectionTimeout: 连接超时时间 redirectPort: 如果发送的是https 请求. 就将请求转发到8443 端口。 (https写默认使用的是443端口,因为tomcat端口都是以8开头,所有这个地方是8443) 使用8009 接受http协议发送过来的请求 <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" useBodyEncodingForURI="true"

Run code in python script on shutdown signal

霸气de小男生 提交于 2019-12-18 12:42:24
问题 I have a python script that runs in the background on startup. The starting method is a entry in a run.sh file which is called with /etc/rc.local. The exact entry would be "sudo python /home/pi/run/main.py &". The system is a raspberry pi with wheezy. The script is running, no problem so far. If a shutdown command is send to the system (via console "sudo shutdown -h now") I need further the script to not abort right away but to execute some code first. Thats what I got so far: #!/usr/bin/env

How do you cleanly abort a Delphi program?

跟風遠走 提交于 2019-12-18 11:07:12
问题 I've got a program that's having some trouble during shutdown, raising exceptions that I can't trace back to their source. It appears to be timing-related and non-deterministic. This is occurring after all shared resources have been released, and since it's shutdown, memory leaks are not an issue, so that makes me wonder if there's any way to just tell the program to terminate immediately and silently after releasing the shared resources, instead of continuing with the shutdown sequence and

redis集群搭建

梦想与她 提交于 2019-12-18 10:51:13
1、下载 cd /usr/local wget http://download.redis.io/releases/redis-3.2.3.tar.gz 2、解压安装 tar -zxvf redis-3.2.3.tar.gz cd redis-3.2.3 安装需要gcc、tcl yum install gcc yum install tcl 安装 make MALLOC=libc make install 3. 修改配置文件redis.conf 新建目录 mkdir /usr/local/redisCluster cd /usr/local/redisCluster 在redisCluster 下新建目录 mkdir 7000 mkdir 7001 mkdir 7002 mkdir 7003 mkdir 7004 mkdir 7005 复制文件到7000 cp -r /usr/local/redis-3.2.3/* /usr/local/redisCluster/7000 修改redis.conf vim /usr/local/redisCluster/7000/redis.conf ##修改配置文件中的下面选项 port 7000 bind ip pidfile /var/run/redis_7000.pid logfile /var/log/redis_7000

How do I get my Java application to shutdown nicely in windows?

你离开我真会死。 提交于 2019-12-18 08:23:48
问题 I have a Java application which I want to shutdown 'nicely' when the user selects Start->Shutdown. I've tried using JVM shutdown listeners via Runtime.addShutdownHook(...) but this doesn't work as I can't use any UI elements from it. I've also tried using the exit handler on my main application UI window but it has no way to pause or halt shutdown as far as I can tell. How can I handle shutdown nicely? 回答1: The previously mentioned JNI approach will likely work. You can use JNA which is