# Need help with Jetty restart using ansible

**URL:** <https://forum.ansible.com/t/need-help-with-jetty-restart-using-ansible/19905>\
**Category:** Ansible Project\
**Created:** [November 30, 2015, 10:10pm UTC](https://forum.ansible.com/t/need-help-with-jetty-restart-using-ansible/19905 "2015-11-30T22:10:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![eric\_hanzl](https://avatars.discourse-cdn.com/v4/letter/e/c57346/32.png) [@eric\_hanzl](https://forum.ansible.com/u/eric_hanzl)\
**Post date:** [November 30, 2015, 10:10pm UTC](https://forum.ansible.com/t/need-help-with-jetty-restart-using-ansible/19905/1 "2015-11-30T22:10:38Z")

</div>

I can restart Jetty with no issues form the command line:

sudo /sbin/service jetty restart

log:

2015-11-30 16:33:38.875:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext@3567135c{/,[file:///tmp/jetty-localhost-8080-api.war-_-any-1507380460644118921.dir/webapp/, jar:file:///tmp/jetty-localhost-8080-api.war-_-any-1507380460644118921.dir/webapp/WEB-INF/lib/myfaces-api-2.2.8.jar!/META-INF/resources],AVAILABLE}{/api.war}

2015-11-30 16:33:38.899:INFO:oejs.ServerConnector:main: Started ServerConnector@12f279b5{HTTP/1.1,[http/1.1]}{localhost:8080}

2015-11-30 16:33:38.899:INFO:oejs.Server:main: Started @9058ms

But I unable to restart using ansible.

Here is my jenkins command to run ansible:

ansible-playbook -c ssh -i stg --extra-vars=“hosts=all” --private-key=~/.ssh/access.key -f 10 jetty-restart.yml

Contents of jetty-restart.yml:

#aritsto-jetty-restart.yml

- **hosts** : “{{ hosts }}”  
**remote\_user** : deployer

**tasks** :

- **name** : Check if Service jetty Exists  
**stat** : path=/etc/init.d/jetty  
**register** : service\_status

_# start jetty using core module_

- **name** : Restart jetty  
**shell** : sudo /sbin/service jetty restart  
_#service: name=jetty enabled=no state=restarted_  
**when** : service\_status.stat.exists

ansible log:

– [api01.stg.ewr1.nytimes.com](http://api01.stg.ewr1.nytimes.com): –

cmd: sudo /sbin/service jetty restart

start: 2015-11-30 16:46:10.636655

end: 2015-11-30 16:46:27.828391

delta: 0:00:17.191736

stdout: Stopping Jetty: OK

Starting Jetty: . . OK Mon Nov 30 16:46:26 EST 2015

stderr: 2015-11-30 16:46:15.310:INFO::main: Logging initialized @526ms

2015-11-30 16:46:15.643:INFO::main: Redirecting stderr/stdout to /opt/jetty-distribution-9.3.0.v20150612/logs/2015\_11\_30.stderrout.log

log:

2015-11-30 16:46:24.101:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext@3567135c{/,[file:///tmp/jetty-localhost-8080-api.war-_-any-4495068837574041021.dir/webapp/, jar:file:///tmp/jetty-localhost-8080-api.war-_-any-4495068837574041021.dir/webapp/WEB-INF/lib/myfaces-api-2.2.8.jar!/META-INF/resources],AVAILABLE}{/-api.war}

2015-11-30 16:46:24.124:INFO:oejs.ServerConnector:main: Started ServerConnector@5807efad{HTTP/1.1,[http/1.1]}{localhost:8080}

2015-11-30 16:46:24.126:INFO:oejs.Server:main: Started @9342ms

2015-11-30 16:46:27.857:INFO:oejs.ServerConnector:Thread-1: Stopped ServerConnector@5807efad{HTTP/1.1,[http/1.1]}{localhost:8080}

[INFO][ebApplicationContext] Closing Root WebApplicationContext: startup date [Mon Nov 30 16:46:19 EST 2015]; root of context hierarchy

2015-11-30 16:46:27.899:INFO:oejsh.ContextHandler:Thread-1: Stopped o.e.j.w.WebAppContext@3567135c{/,[file:///tmp/jetty-localhost-8080-api.war-_-any-4495068837574041021.dir/webapp/, jar:file:///tmp/jetty-localhost-8080-api.war-_-any-4495068837574041021.dir/webapp/WEB-INF/lib/myfaces-api-2.2.8.jar!/META-INF/resources],UNAVAILABLE}{/api.war}

What is causing the jetty service to stop 3 seconds after an apparent successful restart?

---

<div class="post-metadata">

**Author:** ![eric\_hanzl](https://avatars.discourse-cdn.com/v4/letter/e/c57346/32.png) [@eric\_hanzl](https://forum.ansible.com/u/eric_hanzl)\
**Post date:** [December 1, 2015, 2:46pm UTC](https://forum.ansible.com/t/need-help-with-jetty-restart-using-ansible/19905/2 "2015-12-01T14:46:28Z")

</div>

I edited my ansible script to use async mode:

```auto
# restart jetty
- name: Restart jetty
  shell: sudo /sbin/service jetty restart
  when: service_status.stat.exists
  async: 300
  poll: 0

```

```auto

```

```auto
Now i get the restart and jetty stays up!

```
