Home >Java >javaTutorial >Introduction to methods of starting and stopping Java processes in batches (with examples)
This article brings you an introduction to the method of starting and stopping Java processes in batches (with examples). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
java process management program Name: jmanager
Main functions: save all Java process information on the current host, stop Java processes, start Java processes
Problems solved:
The company's current test environment only has a few virtual machines and no container management. The system adopts a distributed architecture and requires many programs to be deployed.
Once the virtual machine restarts or fails, it is very time-consuming and troublesome to use Jenkins to restart the packaging and deployment, so I wrote this script to regularly capture the Java process startup information.
Once a failure occurs, you can stop the Java process in batches or batch Start the Java process.
Applicable environment: Linux system and python3 has been installed, you can execute the jps command
How to install:
git clone https://github.com/mudiyouyou/jmanager.git
Install the following python library
pip3 install json pip3 install psutil
How to do it because of the network It is recommended to use the following command
pip3 install json -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com pip3 install psutil -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
How to operate:
python3 main.py log 解释:记录当前所有java进程信息,产生以当前日志命名的进程数据文件 python3 main.py stop xxxx.json 解释:关闭所有Java进程 xxxx.json 为第一步产生的数据文件 python3 main.py start xxxx.json 解释:启动所有Java进程 xxxx.json 为第一步产生的数据文件
This script is suitable for all java programs and can be installed in other environments, but this script is not responsible for the program startup or stop sequence
The above is the detailed content of Introduction to methods of starting and stopping Java processes in batches (with examples). For more information, please follow other related articles on the PHP Chinese website!