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

Reply via email to