ansible 的任务配置
- name: copy shell file
copy: 'remote_src=no src={{ jenkins_workspace }}/{{ deploy_shell_file }} dest={{ dest_web_path }}/ansible_command/deploy.sh mode=0755 force=yes'
- name: copy jar file
copy: 'remote_src=no src={{ jenkins_workspace }}/{{ deploy_path }}/{{ deploy_file }} dest={{ dest_web_path }}/{{ deploy_file }} mode=0755 force=yes'
- name: restart server
shell: "{{ dest_web_path }}/ansible_command/deploy.sh"
deploy.sh和jar文件都已上传,服务器文件见下图
deploy.sh启动java命令
nohup java -Dspring.profiles.active=prod -jar /apps/bcat-module-csp-2.3.0.jar >/dev/null 2>&1 &
deploy.sh的作用大致就是关闭springboot服务,然后启动springboot,大致的代码见下图
问题:
在web服务器上直接执行deploy.sh可以重启springboot服务成功
由ansible的shell模块执行deploy.sh的时候,能够关闭springboot服务,无法启动springboot服务
登录后可查看更多问答,登录/注册