The best way to start a jar package project under Centos7 server

The best way to start a jar package project under Centos7 server

Preface

Everyone knows how to run a jar package on Linux. Why do I want to talk about it separately? Careful friends may have discovered the keywords Centos7 and best way in the title.

This shows that I am not just writing something casually to write a blogヾ(◍°∇°◍)ノ゙

First of all, Centos7 recommends that we run the project like this

First execute the command:

cd /ets/systemd/system

Go to this directory and create a new file yourProjectName.service. You can set yourProjectName to the service name you want.

Edit a new file with vi

vi yourProjectName.service

file name

[Unit] 
Description=yourProjectName #DescriptionAfter=syslog.target network.target #Depends on [Service] 
Type=simple 

ExecStart=/usr/bin/java -jar /opt/javaapps/yourProjectName.jar 
#The first part is the absolute path of the java command and the second part is the absolute path of the jar package. ExecStop=/bin/kill -15 $MAINPID 

User=root 
Group=root 

[Install] 
WantedBy=multi-user.target

use

systemctl start yourProjectName

or

systemctl start yourProjectName.service

The service is started.

If you change the project:

Run first

systemctl daemon-reload

Then run systemctl start sell.service

To stop the service:

systemctl stop yourProjectName

or

systemctl stop yourProjectName.service

Set the startup to start automatically:

systemctl enable yourProjectName

or

systemctl enable yourProjectName.service

Or if you don't want to start the machine:

systemctl disable yourProjectName

or

systemctl disable yourProjectName.service

Okay, that's all. Running the project in a standardized manner helps with later maintenance.

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM.

You may also be interested in:
  • Linux editing start, stop and restart springboot jar package script example
  • Shell script for one-click restart of Jar package and some experience sharing of new server deployment
  • Linux shell script to start jar package
  • How to start jar package and run it in the background in Linux
  • Steps for automatic restart of jar package at startup under Windows

<<:  Detailed explanation of CocosCreator message distribution mechanism

>>:  Summary of common tool examples in MySQL (recommended)

Recommend

Design perspective technology is an important capital of design ability

A design soldier asked: "Can I just do pure ...

Detailed explanation of Vue options

Table of contents 1. What are options? 2. What at...

Detailed explanation of the function and usage of keepAlive component in Vue

Preface During the interview, many interviewers m...

Introduction to the process of building your own FTP and SFTP servers

FTP and SFTP are widely used as file transfer pro...

Docker installation and configuration steps for Redis image

Table of contents Preface environment Install Cre...

Ubuntu 20.04 Best Configuration Guide (Newbie Essential)

1. System Configuration 1. Turn off sudo password...

How CSS affects the white screen time during initial loading

Rendering pipeline with external css files In the...

How to open external network access rights for mysql

As shown below: Mainly execute authorization comm...

Canvas draws scratch card effect

This article shares the specific code for drawing...

How much do you know about JavaScript inheritance?

Table of contents Preface The relationship betwee...

How to hide elements on the Web and their advantages and disadvantages

Example source code: https://codepen.io/shadeed/p...

Detailed steps for building Portainer visual interface with Docker

In order to solve the problem mentioned last time...

HTML meta usage examples

Example Usage Copy code The code is as follows: &l...