Ask Your Question
0

puppet agent hangs when trying to run node PM2

asked 2015-09-09 04:22:12 -0500

mustafa gravatar image

Following is my puppet code.

 file {
    '/etc/puppet/modules/node_and_git/files/script.sh':
     ensure => 'file',
      source => 'puppet:///modules/node_and_git/script.sh',
      require => Class['order_management'],
      path => '/home/admin/script.sh',
      owner => 'root',
      group => 'root',
      mode  => '0744', # Use 0700 if it is sensitive
      notify => Exec['run_my_script'],
  }
  exec {
    'run_my_script':
     path =>['/usr/bin','/usr/sbin','/bin','/sbin','/usr/local/bin', '/usr/local/sbin'],
     command => '/home/admin/script.sh',
     refreshonly => true,
     timeout => 1800,
  }

In script.sh file I have

#!/bin/bash
yum -y install gcc-c++
cd /home/admin/package/node-v0.12.7
./configure
make
sudo make install
/usr/local/bin/npm install pm2 -g
cd /home/admin/package/Order-Management
pm2 start processes.json

Everything is working fine until the last line. When the puppet client try to execute the last line it hangs. The script run perfectly locally on the client machine. Any help ?? Thanks in advance.

edit retag flag offensive close merge delete

Comments

Does the pm2 process show up in the process list at that point? Have you tried running puppet with the --debug switch to see if there are any interesting messages emitted? Does pm2 depend on any environment variables that need to be set in the exec resource?

GregLarkin gravatar imageGregLarkin ( 2015-09-09 17:40:40 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2015-09-10 11:31:32 -0500

mustafa gravatar image

Hi,

Thanks for your reply. Yes I had to add a environment variable in the exec resource. I was setting the path but looks like it is not enough.

Br, Mustafa

edit flag offensive delete link more
0

answered 2015-09-11 08:47:52 -0500

slk gravatar image

Try running 'pm2' on the background.

pm2 start processes.json & ( notice the & at the end )

edit flag offensive delete link more
0

answered 2016-02-25 10:13:19 -0500

For those that stumble upon this, the answer is to add the HOME environment variable.

see https://github.com/Unitech/PM2/issues... for details.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-09-09 03:54:07 -0500

Seen: 212 times

Last updated: Sep 11 '15