最近帮客户开发了一款B/S架构的软件,但是客户没有linux服务器,只有windows电脑,客户不是很懂IT方面,只希望最简单使用,这样很多linux下的shell命令之类的就无法使用了。目前考虑主要包含以下功能
- 开机自动启动
- 如果某个东西没有正常启动,可以点击一下就启动
网上找了一下原来真有这样的神器,地址如下,截止发稿日star数量11.5K
https://github.com/winsw/winsw
主要过程如下,可以使用全局模式或者捆绑的模式
- 下载exe
- 编写配置文件
- 安装卸载或者查看服务状态
Command | Description |
---|---|
install | Installs the service. |
uninstall | Uninstalls the service. |
start | Starts the service. |
stop | Stops the service. |
restart | Stops and then starts the service. |
status | Checks the status of the service. |
refresh | Refreshes the service properties without reinstallation. |
customize | Customizes the wrapper executable. |
dev | Experimental commands. |
安装nginx作为windows服务
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<logpath>d:\nginx\logs\</logpath>
<logmode>roll</logmode>
<depend></depend>
<executable>d:\nginx\nginx.exe</executable>
<stopexecutable>d:\nginx\nginx.exe -s stop</stopexecutable>
</service>
# 注册服务
.\service.exe install
# 删除服务
.\service.exe uninstall
# 启动服务 nginx-服务id
net start nginx
# 关闭服务
net stop nginx
安装java程序作为系统服务
<service>
<id>foo</id>
<!-- 服务名称-->
<name>foo service </name>
<!-- 服务说明 -->
<description>This is foo service </description>
<!-- 指定程序依赖的 jre -->
<executable>%BASE%\jre\bin\java.exe</executable>
<!-- jar 运行命令 -->
<arguments> -jar %BASE%\jar\app.jar </arguments>
<!-- 输出日志目录 -->
<logpath>%BASE%\logs</logpath>
<!-- %BASE% 为部署主目录 -->
</service>
使用
# 安装服务
foo.exe install
# 启动服务
foo.exe start
# 停止服务
foo.exe stop
# 卸载服务
foo.exe uninstall
项目开发、代码讲解、疑难问题、环境搭建 请联系:gaoyue_13
微信搜一搜:逮猫大兄弟。感谢支持~