More PM2 usage description please refer to: PM2 Simple Manual - Denver
Since PM2 are usually used for node applications, it exec_mode
should be written fork
, the most important thing is args
, -jar
and the location where the jar package should be marked, if the need to provide additional parameters, but also in the args
notation, together.
Suppose you create shown below fz.json
, use the command pm2 start fz.json
to run fz.jar
using the command tail -f /home/imzhizi/log/fz-out.log
can also view the run log.
{
"name": "fz",
"script": "/usr/bin/java",
"args": [
"-jar",
"/home/imzhizi/tcm-fz/target/fz.jar",
"--spring.profiles.active=prod"
],
"exec_interpreter": "",
"exec_mode": "fork",
"error_file" : "/home/imzhizi/log/fz-err.log",
"out_file" : "/home/imzhizi/log/fz-out.log"
}
Some experience:
- After passing through json start, you can directly use the name json file to control the project, such as
pm2 stop name
; - After each re-packaged, use
pm2 restart name
can update the project; - If you modify the json file, it can not by
restart
updating the project, must firstpm2 del name
and then againpm2 start xx.json
.