linux(restart stop status start)自动启动项目并配置日志
Posted 健身小白
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux(restart stop status start)自动启动项目并配置日志相关的知识,希望对你有一定的参考价值。
接上文使用maven 插件生成liunx的restart脚本:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/config</directory>
</resource>
<resource>
<filtering>true</filtering>
<directory>src/main/config</directory>
<includes>
<include>application.properties</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.10</version>
<configuration>
<repositoryLayout>flat</repositoryLayout>
<configurationDirectory>etc</configurationDirectory>
<copyConfigurationDirectory>true</copyConfigurationDirectory>
<includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath>
<repositoryName>lib</repositoryName>
<useWildcardClassPath>true</useWildcardClassPath>
<filterConfigurationDirectory>true</filterConfigurationDirectory>
<daemons>
<daemon>
<id>ex-sqpt-app</id>
<mainClass>cn.yccj.lzsi.external.sqpt.application.SqptApplication</mainClass>
<platforms>
<platform>jsw</platform>
</platforms>
<jvmSettings>
<initialMemorySize>256M</initialMemorySize>
<maxMemorySize>256M</maxMemorySize>
</jvmSettings>
<generatorConfigurations>
<generatorConfiguration>
<generator>jsw</generator>
<includes>
<include>windows-x86-32</include>
<include>windows-x86-64</include>
<include>linux-x86-32</include>
<include>linux-x86-64</include>
<include>macosx-universal-64</include>
</includes>
<configuration>
<property>
<name>configuration.directory.in.classpath.first</name>
<value>$BASEDIR/etc</value>
</property>
<property>
<name>run.as.user.envvar</name>
<value>${expect-target-running-user}</value>
</property>
<property>
<name>wrapper.pidfile</name>
<value>$BASEDIR/bin</value>
</property>
<property>
<name>wrapper.logfile.maxsize</name>
<value>5M</value>
</property>
<property>
<name>wrapper.logfile.maxfiles</name>
<value>1</value>
</property>
</configuration>
</generatorConfiguration>
</generatorConfigurations>
</daemon>
</daemons>
</configuration>
<executions>
<execution>
<id>generate-jsw-scripts</id>
<phase>package</phase>
<goals>
<goal>generate-daemons</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>cn.yccj.lzsi.external.sqpt.application.SqptApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>
生成后目录如下
将最后一级目录ex-xxx
上传linux cd到bin目录 ex-xxxx restart
注意:设置文件夹权限:chmod 777 文件名
chmod 750 文件名 看自己需要
若使用windows上传的文件请修改文件为unix格式
# 打开文件
vi test.sh
# 查看原格式
:set ff
fileformat=dos
# 修改编码格式
:set ff=unix
# 保存退出
:wq
关于org.codehaus.mojo插件请参考
https://www.pkslow.com/archives/codehaus-mojo-exec-maven-plugin
以上是关于linux(restart stop status start)自动启动项目并配置日志的主要内容,如果未能解决你的问题,请参考以下文章
生产环境中使用脚本实现tomcat start|status|stop|restart