zoukankan      html  css  js  c++  java
  • 五. jenkins部署springboot项目(2)--windows环境--服务

    前提:jenkins和springboot运行在同一台机器

    springboot 通过winsw部署为服务

    winsw 下载地址:https://github.com/kohsuke/winsw/releases

    winsw的使用比较简单,下载上面两个文件,和springboot项目jar包一个文件夹下。

    将exe和xml修改成同样的名字

    xml文件内容如下:

    <configuration>
      
       <!-- ID of the service. It should be unique accross the Windows system-->
      <id>market-serverService</id>
      <!-- Display name of the service -->
      <name>market-serverService</name>
      <!-- Service description -->
      <description>贷款超市jar</description>
      
      <!-- Path to the executable, which should be started -->
      <executable>java</executable>
      
      <!--Xmx256m 代表堆内存最大值为256MB -jar后面的是项目名-->
      <arguments>-Xmx256m -jar market-server-1.0-SNAPSHOT.jar</arguments>
      <!--日志模式-->
      <logmode>rotate</logmode>
    
    </configuration>
    

      打开命令行,注意需要管理员身份打开,否则会执行会报错

    D:javamarket>marketService.exe stop
    2018-12-12 17:51:17,583 INFO  - Stopping the service with id 'market-serverService'
    2018-12-12 17:51:17,611 FATAL - WMI Operation failure: AccessDenied
    WMI.WmiException: AccessDenied
       在 WMI.WmiRoot.BaseHandler.CheckError(ManagementBaseObject result)
       在 WMI.WmiRoot.InstanceHandler.Invoke(Object proxy, MethodInfo method, Object[] args)
       在 winsw.WrapperService.Run(String[] _args, ServiceDescriptor descriptor)
       在 winsw.WrapperService.Main(String[] args)
    WMI.WmiException: AccessDenied
       在 WMI.WmiRoot.BaseHandler.CheckError(ManagementBaseObject result)
       在 WMI.WmiRoot.InstanceHandler.Invoke(Object proxy, MethodInfo method, Object[] args)
       在 winsw.WrapperService.Run(String[] _args, ServiceDescriptor descriptor)
       在 winsw.WrapperService.Main(String[] args)

    注册服务:

    D:javamarket>marketService.exe install
    2018-12-12 17:52:44,795 INFO  - Installing the service with id 'market-serverService'

    启动服务:

    D:javamarket>marketService.exe start
    2018-12-12 17:53:20,052 INFO  - Starting the service with id 'market-serverService'

    关闭服务:

    D:javamarket>marketService.exe stop
    2018-12-12 17:52:24,278 INFO  - Stopping the service with id 'market-serverService'

    卸载服务:

    D:javamarket>marketService.exe uninstall
    2018-12-12 17:52:36,735 INFO  - Uninstalling the service with id 'market-serverService'

    重启服务:

    D:javamarket>marketService.exe restart
    2018-12-12 17:54:25,880 INFO  - Restarting the service with id 'market-serverService'

    jenkins配置参考之前记录

    新建一个maven项目,主要配置如下:

    构建主要逻辑是:

    1.git拉取代码到本地

    2.maven编译打包

    3.复制springboot项目jar包到winsw的目录下覆盖,重启服务

    批处理命令:

    copy /y .	argetmarket-server-1.0-SNAPSHOT.jar d:javamarket
    cd D:javamarket
    market-server-1.0-SNAPSHOTService.exe restart
  • 相关阅读:
    BoundsChecker下载
    大型系统内部资源定位的途径
    架构的焦点
    为什么日志只应该有三个级别
    回收站引发ORACLE查询表空间使用缓慢
    题目记录
    广搜入门 待改进的广搜
    归并排序的使用
    大数数组中滚动数组的应用
    多重背包问题
  • 原文地址:https://www.cnblogs.com/gexiaoshan/p/10109882.html
Copyright © 2011-2022 走看看