linux added service

Software running under Linux we usually put him registered as a service, so that we can command open, close and keep the boot functions.

To use this feature, we need to modify the configuration code on spring-boot-maven-plugin is:

<plugins>
 <plugin>
  <groupId> org.springframework.boot </ groupId>
      <artifactId> the Spring-boot- plugin-Maven </ the artifactId>
  <Configuration>
      <Executable> to true </ Executable>
      </ Configuration>
 </ plugin>
</ plugins>

then packaged using mvn package.
Most of the mainstream Linux init.d or use systemd to register the service. Below CentOS6.6 demonstrate init.d registration services; CentOs7.1 to demonstrate systemd registration services.

(1) Install JDK

 download JDK oracle from the official website, note that the choice: jdk-8u51-linux-x64.rpm . This is a special installation package Red Hat linux-based format, the download jdk placed in any directory linux.

 Run the following command to install the JDK:

 

RPM -ivh JDK-8u51-Linux-x64.rpm
(2) Linux-based int.


sudo ln -s /var/apps/test-0.0.1-SNAPSHOT.jar /etc/init.d/test
 where test is the name of our service.
 Start Service:

Service the Test Start
 Stop Service:
Service the Test STOP
 service status:
Service the Test Status
 boot:

chkconfig ON the Test
program logs on at /var/log/test.log, etc. can be viewed using cat or tail command.


(3) the deployment of Linux-based Systemd

in / etc test.service new file under systemd / system / directory /, fill in the following contents:

[Unit]
the Description = the Test
the After = syslog.target
 
[Service]
ExecStart = / usr / bin / -jar /var/apps/test-0.0.1-SNAPSHOT.jar Java
 
[the Install]
WantedBy = multi-user.target
 noted that modifications and back Description ExecStart content in practical use
 to start the service:

systemctl start test
or systemctl start test .service
 stop the service:
systemctl stop test
or systemctl stop test.service
 service status:
systemctl the Test Status
or systemctl status test.service
 boot:
systemctl enable the Test
or systemctl enable test.service
 project log:
journalctl -u the Test
or journalctl -u test.service


Original: https : //blog.csdn.net/ly690226302/article/details/79260875
Disclaimer: This article is a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin www.cnblogs.com/bsw-zhen/p/11115919.html