Launch node server in background

121 views
Skip to first unread message

Neil Young

unread,
Oct 12, 2021, 11:28:57 AM10/12/21
to Ansible Project
Hmm. I must be making again something fundamentally wrong :)

Trying to start a simple node server app into background


    - name: Start server (run as non-privileged user)
      tags: server
      shell: |
        nohup node server.js 2>&1 &
      args:
        chdir: my-server-dir
      become: yes
      become_user: "{{ non_root_user }}"

This runs w/o problems. However, the service is not started...

Running the same command from console works...

It doesn't even run as "sudo" (if f I remove the "become" lines at the end, my entire script runs as sudo)



Neil Young

unread,
Oct 12, 2021, 12:07:54 PM10/12/21
to Ansible Project
Worked around with `forever`, but would like to understand...

Stefan Hornburg (Racke)

unread,
Oct 12, 2021, 12:42:33 PM10/12/21
to ansible...@googlegroups.com
On 12/10/2021 17:28, 'Neil Young' via Ansible Project wrote:
> Hmm. I must be making again something fundamentally wrong :)
>

Yes, you are trying to use Ansible as glorified shell *and* ignore all the options to run a service properly (e.g. with systemd).

Regards
Racke

> Trying to start a simple node server app into background
>
>
>     - name: Start server (run as non-privileged user)
>       tags: server
>       shell: |
>         nohup node server.js 2>&1 &
>       args:
>         chdir: my-server-dir
>       become: yes
>       become_user: "{{ non_root_user }}"
>
> This runs w/o problems. However, the service is not started...
>
> Running the same command from console works...
>
> It doesn't even run as "sudo" (if f I remove the "become" lines at the end, my entire script runs as sudo)
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

OpenPGP_0x5B93015BFA2720F8.asc
OpenPGP_signature

Neil Young

unread,
Oct 12, 2021, 12:43:12 PM10/12/21
to Ansible Project
Thanks for the helpful comment.

Neil Young

unread,
Oct 12, 2021, 12:45:07 PM10/12/21
to Ansible Project
...even though it might not be the high level of "best practice" (in fact you can read a lot of this Racke comments, especially with Ansible) - and I'm surely aware of that - it is a legit shell command.

Stefan Hornburg (Racke)

unread,
Oct 12, 2021, 12:54:35 PM10/12/21
to ansible...@googlegroups.com
On 12/10/2021 18:45, 'Neil Young' via Ansible Project wrote:
> ...even though it might not be the high level of "best practice" (in fact you can read a lot of this Racke comments, especially with Ansible) - and I'm surely aware of that - it is a legit shell command.
>

Yes, but running a server through nohup is certainly bad practice. Nohup is rather provided to prevent long running processes to be disrupted.

There is no really good way to control the server when it is running. How do you stop it for example? Restart it when it is crashed? Etc.

And the shell called from Ansible doesn't have the same environment as when you login as regular user.

Regards
Racke


>
> Neil Young schrieb am Dienstag, 12. Oktober 2021 um 18:43:12 UTC+2:
>
> Thanks for the helpful comment.
>
> ra...@linuxia.de schrieb am Dienstag, 12. Oktober 2021 um 18:42:33 UTC+2:
>
> On 12/10/2021 17:28, 'Neil Young' via Ansible Project wrote:
> > Hmm. I must be making again something fundamentally wrong :)
> >
>
> Yes, you are trying to use Ansible as glorified shell *and* ignore all the options to run a service properly (e.g. with systemd).
>
> Regards
> Racke
>
> > Trying to start a simple node server app into background
> >
> >
> >     - name: Start server (run as non-privileged user)
> >       tags: server
> >       shell: |
> >         nohup node server.js 2>&1 &
> >       args:
> >         chdir: my-server-dir
> >       become: yes
> >       become_user: "{{ non_root_user }}"
> >
> > This runs w/o problems. However, the service is not started...
> >
> > Running the same command from console works...
> >
> > It doesn't even run as "sudo" (if f I remove the "become" lines at the end, my entire script runs as sudo)
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> > To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration.
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer>.
OpenPGP_0x5B93015BFA2720F8.asc
OpenPGP_signature

Neil Young

unread,
Oct 12, 2021, 1:05:00 PM10/12/21
to Ansible Project
Posts disappear here...

However, disregard. IMHO there is nothing wrong with "node server.js &" and I was just trying to figure out why this doesn't work with Ansible. I wasn't looking for a religious discussion.  

Stefan Hornburg (Racke)

unread,
Oct 12, 2021, 1:08:47 PM10/12/21
to ansible...@googlegroups.com
On 12/10/2021 19:04, 'Neil Young' via Ansible Project wrote:
> Posts disappear here...
>
> However, disregard. IMHO there is nothing wrong with "node server.js &" and I was just trying to figure out why this doesn't work with Ansible. I wasn't looking for a religious discussion.
>

Neither me .. just pointing out common sense using Ansible and Unix services.

Regards
Racke
> > > To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com>> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer>>>.
> >
> >
> > --
> > Ecommerce and Linux consulting + Perl and web application programming.
> > Debian and Sympa administration.
> >
> > --
> > You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> > To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration.
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com?utm_medium=email&utm_source=footer>.
OpenPGP_0x5B93015BFA2720F8.asc
OpenPGP_signature

Neil Young

unread,
Oct 12, 2021, 2:00:34 PM10/12/21
to Ansible Project
Look, that sucks meanwhile. The question was: "why is this not working"? Not: Who here is able to teach me best practice?

Because - this is something I can get around the corner.

I give you the last word. Will not respond.

Thanks

Stefan Hornburg (Racke)

unread,
Oct 12, 2021, 2:09:54 PM10/12/21
to ansible...@googlegroups.com
On 12/10/2021 20:00, 'Neil Young' via Ansible Project wrote:
> Look, that sucks meanwhile. The question was: "why is this not working"? Not: Who here is able to teach me best practice?
>
> Because - this is something I can get around the corner.
>
> I give you the last word. Will not respond.
>
> Thanks
>

Fair enough, but the trouble is other users might reuse your questionable examples.
> > > > To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com>> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com>>>
> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer>> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer>
> > <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer>>>>.
> > >
> > >
> > > --
> > > Ecommerce and Linux consulting + Perl and web application programming.
> > > Debian and Sympa administration.
> > >
> > > --
> > > You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> > > To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> > > To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com>> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer>>>.
> >
> >
> > --
> > Ecommerce and Linux consulting + Perl and web application programming.
> > Debian and Sympa administration.
> >
> > --
> > You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> > To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration.
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/61cd4b65-5e7b-4ca2-ab19-9de4bb062644n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/61cd4b65-5e7b-4ca2-ab19-9de4bb062644n%40googlegroups.com?utm_medium=email&utm_source=footer>.
OpenPGP_0x5B93015BFA2720F8.asc
OpenPGP_signature

Neil Young

unread,
Oct 12, 2021, 2:20:52 PM10/12/21
to Ansible Project
Yes, now everyone understands that you've got it.

Anyone else with an answer to the actual question? Why is that not possible?

I don't mean: Why can't you do that?

Stefan Hornburg (Racke)

unread,
Oct 12, 2021, 2:24:53 PM10/12/21
to ansible...@googlegroups.com
On 12/10/2021 20:20, 'Neil Young' via Ansible Project wrote:
> Yes, now everyone understands that you've got it.
>
> Anyone else with an answer to the actual question? Why is that not possible?

Did you try to remove the redirection from your shell command and look at stdout/stderr (with register + debug task)?

Regards
Racke
> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer>>> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer>>
> > > > To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com>> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com>>>
> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer>> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer>
> > <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer>>>>.
> > >
> > >
> > > --
> > > Ecommerce and Linux consulting + Perl and web application programming.
> > > Debian and Sympa administration.
> > >
> > > --
> > > You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> > > To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> > > To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com>> <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com?utm_medium=email&utm_source=footer> <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com?utm_medium=email&utm_source=footer>>>.
> >
> >
> > --
> > Ecommerce and Linux consulting + Perl and web application programming.
> > Debian and Sympa administration.
> >
> > --
> > You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> > To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/61cd4b65-5e7b-4ca2-ab19-9de4bb062644n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/61cd4b65-5e7b-4ca2-ab19-9de4bb062644n%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/61cd4b65-5e7b-4ca2-ab19-9de4bb062644n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/61cd4b65-5e7b-4ca2-ab19-9de4bb062644n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration.
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f593db47-0592-49ef-b36c-3823c97f5a65n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/f593db47-0592-49ef-b36c-3823c97f5a65n%40googlegroups.com?utm_medium=email&utm_source=footer>.
OpenPGP_0x5B93015BFA2720F8.asc
OpenPGP_signature

Neil Young

unread,
Oct 12, 2021, 2:32:57 PM10/12/21
to Ansible Project
OK, then back to the problem:

With and without nohup the same result: The app seems to start, but is killed then. Didn't try debug yet, but the console output looks good:

TASK [Start server (run as non-privileged user)] ******************************************************************************************************************************************************************
changed: [ubuntuVM] => {"changed": true, "cmd": "nohup node wss.js &\n", "delta": "0:00:01.190398", "end": "2021-10-12 18:30:38.791334", "msg": "", "rc": 0, "start": "2021-10-12 18:30:37.600936", "stderr": "", "stderr_lines": [], "stdout": "WSS mock running on port 8080", "stdout_lines": ["WSS mock running on port 8080"]}


TASK [Start server (run as non-privileged user)] ******************************************************************************************************************************************************************
changed: [ubuntuVM] => {"changed": true, "cmd": "node wss.js &\n", "delta": "0:00:01.182786", "end": "2021-10-12 18:31:23.449623", "msg": "", "rc": 0, "start": "2021-10-12 18:31:22.266837", "stderr": "", "stderr_lines": [], "stdout": "WSS mock running on port 8080", "stdout_lines": ["WSS mock running on port 8080"]}




Stefan Hornburg (Racke)

unread,
Oct 12, 2021, 2:43:14 PM10/12/21
to ansible...@googlegroups.com
On 12/10/2021 20:32, 'Neil Young' via Ansible Project wrote:
> OK, then back to the problem:
>
> With and without nohup the same result: The app seems to start, but is killed then. Didn't try debug yet, but the console output looks good:
>
> TASK [Start server (run as non-privileged user)] ******************************************************************************************************************************************************************
> changed: [ubuntuVM] => {"changed": true, "cmd": "nohup node wss.js &\n", "delta": "0:00:01.190398", "end": "2021-10-12 18:30:38.791334", "msg": "", "rc": 0, "start": "2021-10-12 18:30:37.600936", "stderr": "", "stderr_lines": [], "stdout": "WSS mock running on port 8080", "stdout_lines": ["WSS mock running on port 8080"]}
>
>
> TASK [Start server (run as non-privileged user)] ******************************************************************************************************************************************************************
> changed: [ubuntuVM] => {"changed": true, "cmd": "node wss.js &\n", "delta": "0:00:01.182786", "end": "2021-10-12 18:31:23.449623", "msg": "", "rc": 0, "start": "2021-10-12 18:31:22.266837", "stderr": "", "stderr_lines": [], "stdout": "WSS mock running on port 8080", "stdout_lines": ["WSS mock running on port 8080"]}
>
>

My advice would be to write a script that does the nohup with all the redirections instead using it verbatim. See https://stackoverflow.com/questions/41676607/ansible-terminates-my-app-with-nohup for more information. If you do that, switch to command module.
> > <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer>>>> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer>
> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer>> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer>>>
> > > > <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer>> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer>
> <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/7a4f5cee-091b-444c-a265-0a584afadb3fn%40googlegroups.com?utm_medium=email&utm_source=footer>>>>>>.
> > > > >
> > > > >
> > > > > --
> > > > > Ecommerce and Linux consulting + Perl and web application programming.
> > > > > Debian and Sympa administration.
> > > > >
> > > > > --
> > > > > You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> > > > > To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> > > > > To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com>> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com>>>
> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com>> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com>>>>
> > <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer>> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer>
> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer>>> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer> <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/c66e7fcc-3e8e-43b0-adb9-c31925a8f443n%40googlegroups.com?utm_medium=email&utm_source=footer>>
> > > > To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com>> <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com>>>
> <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com?utm_medium=email&utm_source=footer> <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com?utm_medium=email&utm_source=footer>> <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com?utm_medium=email&utm_source=footer>
> > <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/6538e050-b972-4d89-95f3-050d81c44d1an%40googlegroups.com?utm_medium=email&utm_source=footer>>>>.
> > >
> > >
> > > --
> > > Ecommerce and Linux consulting + Perl and web application programming.
> > > Debian and Sympa administration.
> > >
> > > --
> > > You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> > > To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> > > To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/61cd4b65-5e7b-4ca2-ab19-9de4bb062644n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/61cd4b65-5e7b-4ca2-ab19-9de4bb062644n%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/61cd4b65-5e7b-4ca2-ab19-9de4bb062644n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/61cd4b65-5e7b-4ca2-ab19-9de4bb062644n%40googlegroups.com>> <https://groups.google.com/d/msgid/ansible-project/61cd4b65-5e7b-4ca2-ab19-9de4bb062644n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/61cd4b65-5e7b-4ca2-ab19-9de4bb062644n%40googlegroups.com?utm_medium=email&utm_source=footer> <https://groups.google.com/d/msgid/ansible-project/61cd4b65-5e7b-4ca2-ab19-9de4bb062644n%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/ansible-project/61cd4b65-5e7b-4ca2-ab19-9de4bb062644n%40googlegroups.com?utm_medium=email&utm_source=footer>>>.
> >
> >
> > --
> > Ecommerce and Linux consulting + Perl and web application programming.
> > Debian and Sympa administration.
> >
> > --
> > You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> > To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f593db47-0592-49ef-b36c-3823c97f5a65n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/f593db47-0592-49ef-b36c-3823c97f5a65n%40googlegroups.com> <https://groups.google.com/d/msgid/ansible-project/f593db47-0592-49ef-b36c-3823c97f5a65n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/ansible-project/f593db47-0592-49ef-b36c-3823c97f5a65n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration.
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/fc52caed-da3f-45be-8b6c-020f1416fb87n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/fc52caed-da3f-45be-8b6c-020f1416fb87n%40googlegroups.com?utm_medium=email&utm_source=footer>.
OpenPGP_0x5B93015BFA2720F8.asc
OpenPGP_signature

Neil Young

unread,
Oct 12, 2021, 2:50:47 PM10/12/21
to Ansible Project
I know this reference. This was my first attempt before I stripped it down to what is there. Didn't work either.

Neil Young

unread,
Oct 12, 2021, 2:55:49 PM10/12/21
to Ansible Project
Tried again. Same result. No obvious error, but server not started.

./start-wss.sh

#!/bin/sh
# Launch as service
nohup node wss.js </dev/null >/dev/null 2>&1 &


- name: Start server (run as non-privileged user)
  tags: server
  command: ./start-wss.sh
  args:
    chdir: server



Neil Young

unread,
Oct 12, 2021, 2:56:58 PM10/12/21
to Ansible Project
Script works on the node, btw.

Neil Young

unread,
Oct 12, 2021, 2:59:44 PM10/12/21
to Ansible Project
For node I could live with forever, which works fine. But I also have some python scripts to start like so. Maybe to wrap them as service seems the only option then. I'm not aware of a "forever" for python...

Let's bury that.

Neil Young

unread,
Oct 12, 2021, 3:26:38 PM10/12/21
to Ansible Project
Looks like forever is supposed to work with python as well. Let's see

forever start -c python python_script.py

Reply all
Reply to author
Forward
0 new messages