# stop or start application ?

**URL:** <https://forum.ansible.com/t/stop-or-start-application/29648>\
**Category:** Ansible Project\
**Created:** [February 11, 2019, 3:07pm UTC](https://forum.ansible.com/t/stop-or-start-application/29648 "2019-02-11T15:07:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryad9200000](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@ryad9200000](https://forum.ansible.com/u/ryad9200000)\
**Post date:** [February 11, 2019, 3:07pm UTC](https://forum.ansible.com/t/stop-or-start-application/29648/1 "2019-02-11T15:07:21Z")

</div>

Hello,

How to stop or start not a service but an application.

This command works but I would like an “ansible syntax” :

**- name: “stop my application”**  
**command: home/ …/ …/my\_application stop**

This command works but i want an “ansible syntax” please guy.

Thank you very much ansible comunity !! 😉

---

<div class="post-metadata">

**Author:** ![ryad9200000](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@ryad9200000](https://forum.ansible.com/u/ryad9200000)\
**Post date:** [February 12, 2019, 9:30am UTC](https://forum.ansible.com/t/stop-or-start-application/29648/2 "2019-02-12T09:30:25Z")

</div>

hi all,

UPPP please !!

Someone have an idea please guy !! 🙂

---

<div class="post-metadata">

**Author:** ![Sudheer\_S1](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@Sudheer\_S1](https://forum.ansible.com/u/Sudheer_S1)\
**Post date:** [February 12, 2019, 10:06am UTC](https://forum.ansible.com/t/stop-or-start-application/29648/3 "2019-02-12T10:06:11Z")

</div>

If your program 'my\_application' is capable of stopping itself when invoked with argument 'stop', then what you have is correct.

I don't see any Ansible anti-pattern here.

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 12, 2019, 11:04am UTC](https://forum.ansible.com/t/stop-or-start-application/29648/4 "2019-02-12T11:04:20Z")

</div>

Services and an applications are the same things, it's just different semantics.  
It's the way they're being managed that's different.  
I would suggest you create a template task to ensure a systemd unit  
exists, so that it fits in the existing framework to manage services.  
Once you have that, you can use the service module.  
If that means "more ansible" to you, then great.  
Having such a systemd unit in place also has other benefits too, of course.

Dick

---

<div class="post-metadata">

**Author:** ![ryad9200000](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@ryad9200000](https://forum.ansible.com/u/ryad9200000)\
**Post date:** [February 12, 2019, 2:46pm UTC](https://forum.ansible.com/t/stop-or-start-application/29648/5 "2019-02-12T14:46:31Z")

</div>

Thank you for answer Dick Visser,

But can you please give me one exemple with this task:

> > **- name: “stop my application”**  
> > **command: home/ …/ …/my\_application stop**

With syntax ansible so with “service” or “systemd” please Dick.

I think that you are the best, thank you !! 🙂

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 12, 2019, 6:32pm UTC](https://forum.ansible.com/t/stop-or-start-application/29648/6 "2019-02-12T18:32:32Z")

</div>

Hi

That very much depends on what "my\_application" is, what PID files it  
uses (if any), if it's meant to run in the foreground, if it forks,  
how it handlers errors, how it needs to be restarted, reloaded, etc,  
etc.  
It does not have much to do with Ansible, it's generic system administration.  
If you need pointers, search for "systemd unit files".  
This is all assuming that your server OS actually uses systemd as its  
init system (you haven't told us).

Dick
