Windows环境下部署先后端分离项目之开机自动启动篇(Windows Service Wrapper)
windows自动启动jar包和nginx服务器
·
1.准备环境
链接:https://pan.baidu.com/s/12kW0SR2Of5IDFL5Jr_accw?pwd=16ak
提取码:16ak
2.目的
一)前端代码放到nginx里,开机自动启动nginx
二)后端代码直接打成jar包,开机自动启动jar包
3.整活
nginx:
找到nginx.exe根目录
修改为相同的名字,随便起 不过要和.xml里面的Name标签保持一致
打开.xml文件进行编辑
<service>
2 <id>web-start</id>
3 <name>web-start</name>
4 <description>nginx self starting</description>
5
6 /*这个改为你的Nginx路径*/
7 <logpath>Z:\nginx-1.24.0\</logpath>
8 <logmode>roll</logmode>
9 <depend></depend>
10
11 /*这个改为你的Nginx路径*/
12 <executable>Z:\nginx-1.24.0\nginx.exe</executable>
13
14 /*这个改为你的Nginx路径*/
15 <stopexecutable>Z:\nginx-1.24.0\nginx.exe -s stop</stopexecutable>
16 </service>
之后在.xml当前路径下cmd黑窗口,输入你起的名字 如:web-start.exe install
出现下图则注册成功
打开windows服务
就ok了。
jar包
1.启动jar包和启动nginx唯一不同的就是.xml里面的代码
2.代码如下,注意:前后端的启动服务.exe不要名字写重复
<service>
<!-- ID of the service. It should be unique across the Windows system-->
<id>start-java</id>
<!-- Display name of the service -->
<name>start-java</name>
<!-- Service description -->
<description>This service is a service created from a minimal configuration</description>
<executable>java</executable>
<arguments>-jar cxstar-api-rest-1.0.0.jar</arguments>
</service>
4.卸载服务
在.exe根目录cmd 卸载
start-java.exe uninstall
提示出
即删除成功
更多推荐
已为社区贡献1条内容
所有评论(0)