Error saying script is already running - Ansible playbook error

0 votes

I'm trying to start a node program using pm2 via ansible. 

My playbook:

- name: start the application
  become_user: ubuntu
  command: pm2 start app.js -i max
  tags: 
    - app

But i keep getting this error saying the script is already running. I don't understand why..

Feb 8 in Ansible by Kavya
30 views

1 answer to this question.

0 votes

Remove the previous processes before running this script, something like this:

 - name: delete existing pm2 processes if running
   command: "pm2 delete {{ server_id }}"
   ignore_errors: True
   become: yes
   become_user: rw_user


 - name: start pm2 process
   command: 'pm2 start -x -i 4 --name "{{server_id}}" server.js'
   become: yes
   become_user: rw_user
   environment:
    NODE_ENV: "{{server_env}}"
answered Feb 8 by Dee

Related Questions In Ansible

0 votes
1 answer
+13 votes
2 answers
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer