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

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

Feb 8 in Ansible by Kavya

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
    NODE_ENV: "{{server_env}}"
answered Feb 8 by Dee

Related Questions In Ansible

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

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.