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.
>
> 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>.