Re: [ansible-project] Trying to background a start up script

2020-09-03 Thread Sebastian Collins
Touché!

Ok, I understand now. I thought using pm2 involved a lot of tweaking. I was
trying and failing to get it to read my npm dotenv. Instead of trying to
use pm2 to call my app.js directly I have just realised I can use it to
launch it indirectly via npm without having to change any config . Simples!

Thanks for your advice.



On Thu, Sep 3, 2020 at 7:02 PM Stefan Hornburg (Racke) 
wrote:

> On 9/3/20 7:58 PM, Sebastian Collins wrote:
> > I tried the command module before using the shell module.
> >
> > I thought the command module was the wrong choice because when I run it,
> as below, it simply hangs.
> >
> > If I log on to the host I can see the ansible task has spawned the
> node.js process but I suppose my playbook is hanging
> > because it can't background it.
> >
>
> Correct, npm doesn't do that. Use PM2.
>
> Regards
>  Racke
>
> > Any ideas how to do this because the documentation has left me none the
> wiser.
> >
> >tasks:
> >
> >   - name: execute startup script
> > command: npm start app.js
> > register: status
> > args:
> >   chdir: "/apps/test/postcodes.io "
> >
> >   - debug:
> >   var: status
> >
> >
> >
> > On Thu, Sep 3, 2020 at 5:52 PM Stefan Hornburg (Racke)  > wrote:
> >
> > On 9/3/20 5:45 PM, Sebastian Collins wrote:
> > > Thanks for your suggestion. PM2 actually looks really good. Great
> monitoring metrics and ansible seems to
> > > seamlessly invoke it no problem:
> > >
> > > - name: Task17 - start nodejs - Step1 of 3 - execute startup script
> > > shell: pm2 start app.js
> > > register: status
> > > args:
> > >   chdir: "/apps/test/postcodes.io  <
> http://postcodes.io>"
> > >
> > >   - debug:
> > >   var: status
> > > ]
> > >
> >
> > Use command instead of shell module. See documentation.
> >
> >
> > > and provides a handy output to the terminal
> > >
> > >
> > > "stdout": "[PM2] Applying action restartProcessId on app
> [app](ids: [ 0 ])\n[PM2] [app](0) ✓\n[PM2] Process
> > successfully
> > >
> >
>  
> started\n┌─┬┬─┬─┬─┬──┬┬──┬───┬──┬──┬──┬──┐\n│
> > > id  │ name   │ namespace   │ version │ mode│ pid  │ uptime
> │ ↺│ status│ cpu  │ mem  │ user
> > │
> > > watching
> > >
> >
>  
> │\n├─┼┼─┼─┼─┼──┼┼──┼───┼──┼──┼──┼──┤\n│
> > > 0   │ app│ default │ 12.0.0  │ fork│ 59888│ 0s
> │ 1│ online│ 0%   │ 8.7mb│
> > wasadm   │
> > > disabled
> > >
> >
>  
> │\n└─┴┴─┴─┴─┴──┴┴──┴───┴──┴──┴──┴──┘",
> > > "stdout_lines": [
> > > "[PM2] Applying action restartProcessId on app
> [app](ids: [ 0 ])",
> > > "[PM2] [app](0) ✓",
> > > "[PM2] Process successfully started",
> > >
> > >
> >
>  
> "┌─┬┬─┬─┬─┬──┬┬──┬───┬──┬──┬──┬──┐",
> > > "│ id  │ name   │ namespace   │ version │ mode│
> pid  │ uptime │ ↺│ status│ cpu  │
> > mem
> > >│ user │ watching │",
> > >
> > >
> >
>  
> "├─┼┼─┼─┼─┼──┼┼──┼───┼──┼──┼──┼──┤",
> > > "│ 0   │ app│ default │ 12.0.0  │ fork│
> 59888│ 0s │ 1│ online│ 0%   │
> > 8.7mb
> > >│ wasadm   │ disabled │",
> > >
> > >
> >
>  
> "└─┴┴─┴─┴─┴──┴┴──┴───┴──┴──┴──┴──┘"
> > > ]
> > > }
> > > }
> > >
> > >
> > > However, using pm2 has introduced other problems such as me
> failing to have it read the process.env file that node had
> > > no issues with so now I am not listening on the intended port with
> the custom credentials. No doubt there is a way
> > to do
> > > this but  before looking at adopting pm2 is there not just a
> simple fix to my existing ansible task in order to launch
> > > "node start" and keep that process up and running?
> > >
> >
> > I'm sure that pm2 can regard your process.env file, but I think that
> is beyond the topic of this group.
> >
> > And no, I neither have or want "just" a fix for your inferior hack,
> sorry.
> >
> > Regards
> >  Racke
> >
> > >
> > >
> > > On Thu, Sep 3, 2020 at 1:20 PM Stefan Hornburg (Racke) <
> ra...@linuxia.de 

Re: [ansible-project] Trying to background a start up script

2020-09-03 Thread Stefan Hornburg (Racke)
On 9/3/20 7:58 PM, Sebastian Collins wrote:
> I tried the command module before using the shell module.
> 
> I thought the command module was the wrong choice because when I run it, as 
> below, it simply hangs.
> 
> If I log on to the host I can see the ansible task has spawned the node.js 
> process but I suppose my playbook is hanging
> because it can't background it.
> 

Correct, npm doesn't do that. Use PM2.

Regards
 Racke

> Any ideas how to do this because the documentation has left me none the wiser.
> 
>    tasks:
> 
>   - name: execute startup script
> command: npm start app.js
> register: status
> args:
>   chdir: "/apps/test/postcodes.io "
> 
>   - debug:
>   var: status
> 
> 
> 
> On Thu, Sep 3, 2020 at 5:52 PM Stefan Hornburg (Racke)  > wrote:
> 
> On 9/3/20 5:45 PM, Sebastian Collins wrote:
> > Thanks for your suggestion. PM2 actually looks really good. Great 
> monitoring metrics and ansible seems to
> > seamlessly invoke it no problem:
> >
> > - name: Task17 - start nodejs - Step1 of 3 - execute startup script
> > shell: pm2 start app.js
> > register: status
> > args:
> >   chdir: "/apps/test/postcodes.io  
> "
> > 
> >   - debug:
> >   var: status
> > ]
> >
> 
> Use command instead of shell module. See documentation.
> 
> 
> > and provides a handy output to the terminal 
> >
> >
> > "stdout": "[PM2] Applying action restartProcessId on app [app](ids: [ 0 
> ])\n[PM2] [app](0) ✓\n[PM2] Process
> successfully
> >
> 
> started\n┌─┬┬─┬─┬─┬──┬┬──┬───┬──┬──┬──┬──┐\n│
> > id  │ name   │ namespace   │ version │ mode    │ pid      │ uptime │ ↺  
>   │ status    │ cpu      │ mem      │ user
>     │
> > watching
> >
> 
> │\n├─┼┼─┼─┼─┼──┼┼──┼───┼──┼──┼──┼──┤\n│
> > 0   │ app    │ default     │ 12.0.0  │ fork    │ 59888    │ 0s     │ 1  
>   │ online    │ 0%       │ 8.7mb    │
> wasadm   │
> > disabled
> >
> 
> │\n└─┴┴─┴─┴─┴──┴┴──┴───┴──┴──┴──┴──┘",
> >         "stdout_lines": [
> >             "[PM2] Applying action restartProcessId on app [app](ids: [ 
> 0 ])",
> >             "[PM2] [app](0) ✓",
> >             "[PM2] Process successfully started",
> >            
> >
> 
> "┌─┬┬─┬─┬─┬──┬┬──┬───┬──┬──┬──┬──┐",
> >             "│ id  │ name   │ namespace   │ version │ mode    │ pid     
>  │ uptime │ ↺    │ status    │ cpu      │
> mem  
> >    │ user     │ watching │",
> >            
> >
> 
> "├─┼┼─┼─┼─┼──┼┼──┼───┼──┼──┼──┼──┤",
> >             "│ 0   │ app    │ default     │ 12.0.0  │ fork    │ 59888   
>  │ 0s     │ 1    │ online    │ 0%       │
> 8.7mb
> >    │ wasadm   │ disabled │",
> >            
> >
> 
> "└─┴┴─┴─┴─┴──┴┴──┴───┴──┴──┴──┴──┘"
> >         ]
> >     }
> > }
> >
> >
> > However, using pm2 has introduced other problems such as me failing to 
> have it read the process.env file that node had
> > no issues with so now I am not listening on the intended port with the 
> custom credentials. No doubt there is a way
> to do
> > this but  before looking at adopting pm2 is there not just a simple fix 
> to my existing ansible task in order to launch
> > "node start" and keep that process up and running?
> >
> 
> I'm sure that pm2 can regard your process.env file, but I think that is 
> beyond the topic of this group.
> 
> And no, I neither have or want "just" a fix for your inferior hack, sorry.
> 
> Regards
>          Racke
> 
> >
> >
> > On Thu, Sep 3, 2020 at 1:20 PM Stefan Hornburg (Racke) 
> mailto:ra...@linuxia.de>
> >> wrote:
> >
> >     On 9/3/20 2:07 PM, Sebastian Collins wrote:
> >     > Hi,
> >     >
> >     > I have this task and I can't for the life of me get it to keep 
> the process running. I have added in some
> debug and it
> >     > shows me the process is getting shutdown almost immediately after 
> it is started up as can be seen by the end
> time
> >     in the
> >     > output I have provided below. Please advise h

Re: [ansible-project] Trying to background a start up script

2020-09-03 Thread Sebastian Collins
I tried the command module before using the shell module.

I thought the command module was the wrong choice because when I run it, as
below, it simply hangs.

If I log on to the host I can see the ansible task has spawned the node.js
process but I suppose my playbook is hanging because it can't background it.

Any ideas how to do this because the documentation has left me none the
wiser.

   tasks:

  - name: execute startup script
command: npm start app.js
register: status
args:
  chdir: "/apps/test/postcodes.io"

  - debug:
  var: status



On Thu, Sep 3, 2020 at 5:52 PM Stefan Hornburg (Racke) 
wrote:

> On 9/3/20 5:45 PM, Sebastian Collins wrote:
> > Thanks for your suggestion. PM2 actually looks really good. Great
> monitoring metrics and ansible seems to
> > seamlessly invoke it no problem:
> >
> > - name: Task17 - start nodejs - Step1 of 3 - execute startup script
> > shell: pm2 start app.js
> > register: status
> > args:
> >   chdir: "/apps/test/postcodes.io "
> >
> >   - debug:
> >   var: status
> > ]
> >
>
> Use command instead of shell module. See documentation.
>
>
> > and provides a handy output to the terminal
> >
> >
> > "stdout": "[PM2] Applying action restartProcessId on app [app](ids: [ 0
> ])\n[PM2] [app](0) ✓\n[PM2] Process successfully
> >
> started\n┌─┬┬─┬─┬─┬──┬┬──┬───┬──┬──┬──┬──┐\n│
> > id  │ name   │ namespace   │ version │ mode│ pid  │ uptime │ ↺
>  │ status│ cpu  │ mem  │ user │
> > watching
> >
> │\n├─┼┼─┼─┼─┼──┼┼──┼───┼──┼──┼──┼──┤\n│
> > 0   │ app│ default │ 12.0.0  │ fork│ 59888│ 0s │ 1
>  │ online│ 0%   │ 8.7mb│ wasadm   │
> > disabled
> >
> │\n└─┴┴─┴─┴─┴──┴┴──┴───┴──┴──┴──┴──┘",
> > "stdout_lines": [
> > "[PM2] Applying action restartProcessId on app [app](ids: [
> 0 ])",
> > "[PM2] [app](0) ✓",
> > "[PM2] Process successfully started",
> >
> >
> "┌─┬┬─┬─┬─┬──┬┬──┬───┬──┬──┬──┬──┐",
> > "│ id  │ name   │ namespace   │ version │ mode│ pid
>  │ uptime │ ↺│ status│ cpu  │ mem
> >│ user │ watching │",
> >
> >
> "├─┼┼─┼─┼─┼──┼┼──┼───┼──┼──┼──┼──┤",
> > "│ 0   │ app│ default │ 12.0.0  │ fork│ 59888
>  │ 0s │ 1│ online│ 0%   │ 8.7mb
> >│ wasadm   │ disabled │",
> >
> >
> "└─┴┴─┴─┴─┴──┴┴──┴───┴──┴──┴──┴──┘"
> > ]
> > }
> > }
> >
> >
> > However, using pm2 has introduced other problems such as me failing to
> have it read the process.env file that node had
> > no issues with so now I am not listening on the intended port with the
> custom credentials. No doubt there is a way to do
> > this but  before looking at adopting pm2 is there not just a simple fix
> to my existing ansible task in order to launch
> > "node start" and keep that process up and running?
> >
>
> I'm sure that pm2 can regard your process.env file, but I think that is
> beyond the topic of this group.
>
> And no, I neither have or want "just" a fix for your inferior hack, sorry.
>
> Regards
>  Racke
>
> >
> >
> > On Thu, Sep 3, 2020 at 1:20 PM Stefan Hornburg (Racke)  > wrote:
> >
> > On 9/3/20 2:07 PM, Sebastian Collins wrote:
> > > Hi,
> > >
> > > I have this task and I can't for the life of me get it to keep the
> process running. I have added in some debug and it
> > > shows me the process is getting shutdown almost immediately after
> it is started up as can be seen by the end time
> > in the
> > > output I have provided below. Please advise how I can fix this so
> that the process keeps on running as future
> > tasks are
> > > performed.
> > >
> > >
> > >   - hosts: nodes
> > > remote_user: root
> > > become_user: test
> > > become: true
> > > tasks:
> > >
> > >   - name: execute startup script
> > > shell: nohup npm start > test.out 2>&1 &
> > > register: status
> > > args:
> > >   chdir: "/apps/test/postcodes.io "
> > >
> > >   - debug:
> > >   var: status
> > >
> > >
> >
> > Use a proper daemon process manager (PM2, https://pm2.keymetrics.io/
> ).
> >
> > Regards
> > Racke
> 

Re: [ansible-project] Trying to background a start up script

2020-09-03 Thread Stefan Hornburg (Racke)
On 9/3/20 5:45 PM, Sebastian Collins wrote:
> Thanks for your suggestion. PM2 actually looks really good. Great monitoring 
> metrics and ansible seems to
> seamlessly invoke it no problem:
> 
> - name: Task17 - start nodejs - Step1 of 3 - execute startup script
> shell: pm2 start app.js
> register: status
> args:
>   chdir: "/apps/test/postcodes.io "
> 
>   - debug:
>   var: status
> ]
> 

Use command instead of shell module. See documentation.


> and provides a handy output to the terminal 
> 
> 
> "stdout": "[PM2] Applying action restartProcessId on app [app](ids: [ 0 
> ])\n[PM2] [app](0) ✓\n[PM2] Process successfully
> started\n┌─┬┬─┬─┬─┬──┬┬──┬───┬──┬──┬──┬──┐\n│
> id  │ name   │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ 
> status    │ cpu      │ mem      │ user     │
> watching
> │\n├─┼┼─┼─┼─┼──┼┼──┼───┼──┼──┼──┼──┤\n│
> 0   │ app    │ default     │ 12.0.0  │ fork    │ 59888    │ 0s     │ 1    │ 
> online    │ 0%       │ 8.7mb    │ wasadm   │
> disabled
> │\n└─┴┴─┴─┴─┴──┴┴──┴───┴──┴──┴──┴──┘",
>         "stdout_lines": [
>             "[PM2] Applying action restartProcessId on app [app](ids: [ 0 ])",
>             "[PM2] [app](0) ✓",
>             "[PM2] Process successfully started",
>            
> "┌─┬┬─┬─┬─┬──┬┬──┬───┬──┬──┬──┬──┐",
>             "│ id  │ name   │ namespace   │ version │ mode    │ pid      │ 
> uptime │ ↺    │ status    │ cpu      │ mem  
>    │ user     │ watching │",
>            
> "├─┼┼─┼─┼─┼──┼┼──┼───┼──┼──┼──┼──┤",
>             "│ 0   │ app    │ default     │ 12.0.0  │ fork    │ 59888    │ 0s 
>     │ 1    │ online    │ 0%       │ 8.7mb
>    │ wasadm   │ disabled │",
>            
> "└─┴┴─┴─┴─┴──┴┴──┴───┴──┴──┴──┴──┘"
>         ]
>     }
> }
> 
> 
> However, using pm2 has introduced other problems such as me failing to have 
> it read the process.env file that node had
> no issues with so now I am not listening on the intended port with the custom 
> credentials. No doubt there is a way to do
> this but  before looking at adopting pm2 is there not just a simple fix to my 
> existing ansible task in order to launch
> "node start" and keep that process up and running?
> 

I'm sure that pm2 can regard your process.env file, but I think that is beyond 
the topic of this group.

And no, I neither have or want "just" a fix for your inferior hack, sorry.

Regards
 Racke

> 
> 
> On Thu, Sep 3, 2020 at 1:20 PM Stefan Hornburg (Racke)  > wrote:
> 
> On 9/3/20 2:07 PM, Sebastian Collins wrote:
> > Hi,
> >
> > I have this task and I can't for the life of me get it to keep the 
> process running. I have added in some debug and it
> > shows me the process is getting shutdown almost immediately after it is 
> started up as can be seen by the end time
> in the
> > output I have provided below. Please advise how I can fix this so that 
> the process keeps on running as future
> tasks are
> > performed.
> >
> >   
> >   - hosts: nodes
> > remote_user: root
> > become_user: test
> > become: true
> > tasks:
> >
> >   - name: execute startup script
> > shell: nohup npm start > test.out 2>&1 &
> > register: status
> > args:
> >   chdir: "/apps/test/postcodes.io "
> > 
> >   - debug:
> >   var: status
> >
> >
> 
> Use a proper daemon process manager (PM2, https://pm2.keymetrics.io/).
> 
> Regards
>         Racke
> 
> > Output:
> >
> > TASK [execute startup script] 
> 
> > changed: [host] => {"changed": true, "cmd": "nohup npm start > test.out 
> 2>&1 &", "delta": "0:00:00.006275", "end":
> > "2020-09-03 12:37:51.797561", "rc": 0, "start": "2020-09-03 
> 12:37:51.791286", "stderr": "", "stderr_lines": [],
> > "stdout": "", "stdout_lines": []}
> >
> > TASK [debug]
> > 
> **
> > ok: [host] => {
> >     "status": {
> >         "changed": true,
> >         "cmd": "nohup npm start > test.out 2>&1 &",
> >         "delta": "0:00:00.006275",
> >         

Re: [ansible-project] Trying to background a start up script

2020-09-03 Thread Sebastian Collins
Thanks for your suggestion. PM2 actually looks really good. Great
monitoring metrics and ansible seems to seamlessly invoke it no problem:

- name: Task17 - start nodejs - Step1 of 3 - execute startup script
shell: pm2 start app.js
register: status
args:
  chdir: "/apps/test/postcodes.io"

  - debug:
  var: status
]

and provides a handy output to the terminal


"stdout": "[PM2] Applying action restartProcessId on app [app](ids: [ 0
])\n[PM2] [app](0) ✓\n[PM2] Process successfully
started\n┌─┬┬─┬─┬─┬──┬┬──┬───┬──┬──┬──┬──┐\n│
id  │ name   │ namespace   │ version │ mode│ pid  │ uptime │ ↺│
status│ cpu  │ mem  │ user │ watching
│\n├─┼┼─┼─┼─┼──┼┼──┼───┼──┼──┼──┼──┤\n│
0   │ app│ default │ 12.0.0  │ fork│ 59888│ 0s │ 1│
online│ 0%   │ 8.7mb│ wasadm   │ disabled
│\n└─┴┴─┴─┴─┴──┴┴──┴───┴──┴──┴──┴──┘",
"stdout_lines": [
"[PM2] Applying action restartProcessId on app [app](ids: [ 0
])",
"[PM2] [app](0) ✓",
"[PM2] Process successfully started",

"┌─┬┬─┬─┬─┬──┬┬──┬───┬──┬──┬──┬──┐",
"│ id  │ name   │ namespace   │ version │ mode│ pid  │
uptime │ ↺│ status│ cpu  │ mem  │ user │ watching │",

"├─┼┼─┼─┼─┼──┼┼──┼───┼──┼──┼──┼──┤",
"│ 0   │ app│ default │ 12.0.0  │ fork│ 59888│
0s │ 1│ online│ 0%   │ 8.7mb│ wasadm   │ disabled │",

"└─┴┴─┴─┴─┴──┴┴──┴───┴──┴──┴──┴──┘"
]
}
}


However, using pm2 has introduced other problems such as me failing to have
it read the process.env file that node had no issues with so now I am not
listening on the intended port with the custom credentials. No doubt there
is a way to do this but  before looking at adopting pm2 is there not just a
simple fix to my existing ansible task in order to launch "node start" and
keep that process up and running?



On Thu, Sep 3, 2020 at 1:20 PM Stefan Hornburg (Racke) 
wrote:

> On 9/3/20 2:07 PM, Sebastian Collins wrote:
> > Hi,
> >
> > I have this task and I can't for the life of me get it to keep the
> process running. I have added in some debug and it
> > shows me the process is getting shutdown almost immediately after it is
> started up as can be seen by the end time in the
> > output I have provided below. Please advise how I can fix this so that
> the process keeps on running as future tasks are
> > performed.
> >
> >
> >   - hosts: nodes
> > remote_user: root
> > become_user: test
> > become: true
> > tasks:
> >
> >   - name: execute startup script
> > shell: nohup npm start > test.out 2>&1 &
> > register: status
> > args:
> >   chdir: "/apps/test/postcodes.io"
> >
> >   - debug:
> >   var: status
> >
> >
>
> Use a proper daemon process manager (PM2, https://pm2.keymetrics.io/).
>
> Regards
> Racke
>
> > Output:
> >
> > TASK [execute startup script]
> 
> > changed: [host] => {"changed": true, "cmd": "nohup npm start > test.out
> 2>&1 &", "delta": "0:00:00.006275", "end":
> > "2020-09-03 12:37:51.797561", "rc": 0, "start": "2020-09-03
> 12:37:51.791286", "stderr": "", "stderr_lines": [],
> > "stdout": "", "stdout_lines": []}
> >
> > TASK [debug]
> >
> **
> > ok: [host] => {
> > "status": {
> > "changed": true,
> > "cmd": "nohup npm start > test.out 2>&1 &",
> > "delta": "0:00:00.006275",
> > "end": "2020-09-03 12:37:51.797561",
> > "failed": false,
> > "rc": 0,
> > "start": "2020-09-03 12:37:51.791286",
> > "stderr": "",
> > "stderr_lines": [],
> > "stdout": "",
> > "stdout_lines": []
> > }
> > }
> >
> > If I go on to the host and run it manually it works:
> >
> > host:APACHE >nohup npm start > host.out 2>&1 &
> > [1] 45428
> > user@host:/apps/test/postcodes.io
> > host:APACHE > ps -ef | grep node
> > user   45439 45428  3 12:54 pts/200:00:00 node server.js
> >
> >
> > Any help much appreciated.
> >
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emai

Re: [ansible-project] Trying to background a start up script

2020-09-03 Thread Stefan Hornburg (Racke)
On 9/3/20 2:07 PM, Sebastian Collins wrote:
> Hi,
> 
> I have this task and I can't for the life of me get it to keep the process 
> running. I have added in some debug and it
> shows me the process is getting shutdown almost immediately after it is 
> started up as can be seen by the end time in the
> output I have provided below. Please advise how I can fix this so that the 
> process keeps on running as future tasks are
> performed.
> 
>   
>   - hosts: nodes
> remote_user: root
> become_user: test
> become: true
> tasks:
> 
>   - name: execute startup script
> shell: nohup npm start > test.out 2>&1 &
> register: status
> args:
>   chdir: "/apps/test/postcodes.io"
> 
>   - debug:
>   var: status
> 
> 

Use a proper daemon process manager (PM2, https://pm2.keymetrics.io/).

Regards
Racke

> Output:
> 
> TASK [execute startup script] 
> 
> changed: [host] => {"changed": true, "cmd": "nohup npm start > test.out 2>&1 
> &", "delta": "0:00:00.006275", "end":
> "2020-09-03 12:37:51.797561", "rc": 0, "start": "2020-09-03 12:37:51.791286", 
> "stderr": "", "stderr_lines": [],
> "stdout": "", "stdout_lines": []}
> 
> TASK [debug]
> **
> ok: [host] => {
>     "status": {
>         "changed": true,
>         "cmd": "nohup npm start > test.out 2>&1 &",
>         "delta": "0:00:00.006275",
>         "end": "2020-09-03 12:37:51.797561",
>         "failed": false,
>         "rc": 0,
>         "start": "2020-09-03 12:37:51.791286",
>         "stderr": "",
>         "stderr_lines": [],
>         "stdout": "",
>         "stdout_lines": []
>     }
> }
> 
> If I go on to the host and run it manually it works:
> 
> host:APACHE >nohup npm start > host.out 2>&1 &
> [1]     45428
> user@host:/apps/test/postcodes.io
> host:APACHE > ps -ef | grep node
> user   45439 45428  3 12:54 pts/2    00:00:00 node server.js
> 
> 
> Any help much appreciated.
> 
> 
> -- 
> 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-project+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/02be6001-7a5f-4f13-b478-199947412270n%40googlegroups.com
> .


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

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/bd730ce8-9abc-cce9-1854-14457cd27475%40linuxia.de.


signature.asc
Description: OpenPGP digital signature


[ansible-project] Trying to background a start up script

2020-09-03 Thread Sebastian Collins
Hi,

I have this task and I can't for the life of me get it to keep the process 
running. I have added in some debug and it shows me the process is getting 
shutdown almost immediately after it is started up as can be seen by the 
end time in the output I have provided below. Please advise how I can fix 
this so that the process keeps on running as future tasks are performed.

  
  - hosts: nodes
remote_user: root
become_user: test
become: true
tasks:

  - name: execute startup script
shell: nohup npm start > test.out 2>&1 &
register: status
args:
  chdir: "/apps/test/postcodes.io"

  - debug:
  var: status


Output:

TASK [execute startup script] 

changed: [host] => {"changed": true, "cmd": "nohup npm start > test.out 
2>&1 &", "delta": "0:00:00.006275", "end": "2020-09-03 12:37:51.797561", 
"rc": 0, "start": "2020-09-03 12:37:51.791286", "stderr": "", 
"stderr_lines": [], "stdout": "", "stdout_lines": []}

TASK [debug] 
**
ok: [host] => {
"status": {
"changed": true,
"cmd": "nohup npm start > test.out 2>&1 &",
"delta": "0:00:00.006275",
"end": "2020-09-03 12:37:51.797561",
"failed": false,
"rc": 0,
"start": "2020-09-03 12:37:51.791286",
"stderr": "",
"stderr_lines": [],
"stdout": "",
"stdout_lines": []
}
}

If I go on to the host and run it manually it works:

host:APACHE > nohup npm start > host.out 2>&1 &
[1] 45428
user@host:/apps/test/postcodes.io
host:APACHE > ps -ef | grep node
user   45439 45428  3 12:54 pts/200:00:00 node server.js


Any help much appreciated.


-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/02be6001-7a5f-4f13-b478-199947412270n%40googlegroups.com.