Skip to content

Commit

Permalink
add max_restarts and min_uptime
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Jan 27, 2016
1 parent d3003ea commit 66572ef
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Detailed Usage:
pm2_version => "latest",
install_root => '/opt',
install_dir => 'nodejs',
max_restarts => 10,
min_uptime => 3500,
deamon_user => 'nodejs',
}

Expand All @@ -44,6 +46,8 @@ Detailed Usage:
env => '{ "env.NODE_ENV" : "test" }',
install_root => '/opt',
install_dir => 'nodejs',
max_restarts => 10,
min_uptime => 3500,
deamon_user => 'nodejs',
require => Class['pm2']
}
Expand Down
24 changes: 13 additions & 11 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
# install nodejs and pm2 to be able run nodejs apps
#
class pm2(
$npm_repository = 'https://registry.npmjs.org',
$npm_auth = '',
$npm_always_auth = false,
$npm_email = '[email protected]',
$pm2_version = 'latest',
$install_root = '/opt',
$install_dir = 'nodejs',
$node_dir = '/usr/local/node/node-default',
$deamon_user = 'nodejs',
$nar_deployment = false,
$nar_version = 'latest',)
$npm_repository = 'https://registry.npmjs.org',
$npm_auth = '',
$npm_always_auth = false,
$npm_email = '[email protected]',
$pm2_version = 'latest',
$install_root = '/opt',
$install_dir = 'nodejs',
$node_dir = '/usr/local/node/node-default',
$max_restarts = 10,
$min_uptime = 3500,
$deamon_user = 'nodejs',
$nar_deployment = false,
$nar_version = 'latest',)
{

$install_path = "${install_root}/${install_dir}"
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "neillturner-pm2",
"version": "0.0.7",
"version": "0.0.8",
"author": "neillturner",
"license": "Apache License, Version 2.0",
"summary": "Manage Nodejs Apps with PM2",
Expand Down
2 changes: 2 additions & 0 deletions templates/deploy_app.sh.erb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ cat <<EOF > "$apppath/pm2.json"
"name": "$name",
"script": "$apppath/current/node_modules/$name/$appscript",
"args": $appargs,
"max_restarts": "<%= @max_restarts %>",
"min_uptime": "<%= @min_uptime %>",
"env": $appenv,
"error_file" : "/var/log/pm2/$name/error.log",
"out_file" : "/var/log/pm2/$name/out.log",
Expand Down
2 changes: 2 additions & 0 deletions templates/deploy_app_nar.sh.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ cat <<EOF > "$apppath/pm2.json"
"name": "$name",
"script": "$apppath/current/node_modules/$name/$appscript",
"args": $appargs,
"max_restarts": "<%= @max_restarts %>",
"min_uptime": "<%= @min_uptime %>",
"env": $appenv,
"error_file" : "/var/log/pm2/$name/error.log",
"out_file" : "/var/log/pm2/$name/out.log",
Expand Down
2 changes: 2 additions & 0 deletions templates/pm2.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"name": "<%= @name %>",
"script": "<%= "#{@path}/current/node_modules/#{@name}/#{@script}" %>",
"args": "<%= @args || @args.to_a.to_json.gsub('"', "'") %>",
"max_restarts": "<%= @max_restarts %>",
"min_uptime" : "<%= @min_uptime %>",
"env": <%= @env || {}.to_json %>,
"error_file" : "/var/log/pm2/<%= @name %>/error.log",
"out_file" : "/var/log/pm2/<%= @name %>/out.log",
Expand Down

0 comments on commit 66572ef

Please sign in to comment.