-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate mongodb.pp. Script generation moved to mongodb_script.pp. In…
…tegrate server process operation with server_process.cpp. fixes #4518
- Loading branch information
Masahiro Nakagawa
committed
Jun 20, 2011
1 parent
3ad4748
commit 3935dfc
Showing
3 changed files
with
108 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,46 @@ | ||
# sedue::mongodb assumes sedue::supervise already called | ||
|
||
define sedue::mongodb($user, $instance, $port, $pair, $run) { | ||
define sedue::mongodb($user, $instance, $port, $pair, $run) { | ||
if $run { | ||
$server_sleep_interval = 3 | ||
$server_name = 'mongodb' | ||
$server_type = 'db' | ||
$server_script_name = $server_name | ||
|
||
if $pair { | ||
$mongodb_options = "--port ${port} --nohttpinterface --oplogSize 4096 --master --slave --source ${pair} --autoresync --quiet" | ||
} else { | ||
$mongodb_options = "--port ${port} --nohttpinterface --quiet" | ||
} | ||
|
||
file { "sedue::${instance}_mongodb_directory_repos": | ||
file { "sedue::${instance}::mongodb::directory_repos": | ||
path => "${sedue_home}/repos/${instance}", | ||
owner => $user, | ||
group => $user, | ||
mode => '0755', | ||
ensure => 'directory' | ||
} | ||
|
||
# generate files for serve supervise | ||
file { "sedue::${instance}_mongodb_run_file": | ||
path => "${sedue_home}/etc/serve/${instance}/mongodb.run", | ||
owner => $user, | ||
group => $user, | ||
mode => '0755', | ||
content => template("sedue/mongodb.run.erb"), | ||
require => File["${instance}_serve_directory"] | ||
} | ||
|
||
file { "sedue::${instance}_mongodb_run_directory": | ||
path => "${sedue_home}/etc/serve/${instance}/mongodb", | ||
owner => $user, | ||
group => $user, | ||
mode => '0755', | ||
ensure => 'directory', | ||
require => File["${instance}_serve_directory"] | ||
} | ||
|
||
file { "sedue::${instance}_mongodb_run_symlink": | ||
path => "${sedue_home}/etc/serve/${instance}/mongodb/run", | ||
ensure => 'link', | ||
target => "${sedue_home}/etc/serve/${instance}/mongodb.run", | ||
require => [File["sedue::${instance}_mongodb_run_file"], File["sedue::${instance}_mongodb_run_directory"]] | ||
# generate script and then run it | ||
sedue::mongodb_script { "sedue::${instance}::mongodb::script": | ||
user => $user, | ||
instance => $instance, | ||
port => $port, | ||
pair => $pair, | ||
run => $run, | ||
require => File["sedue::${instance}::mongodb::directory_repos"] | ||
} | ||
|
||
file { "sedue::${instance}_mongodb_init_script": | ||
path => "${sedue_home}/etc/init.d/mongodb-${instance}", | ||
owner => $user, | ||
group => $user, | ||
mode => '0755', | ||
content => template("sedue/server.init.d.erb") | ||
} | ||
|
||
service { "sedue::${instance}_mongodb_process": | ||
path => "${sedue_home}/etc/init.d/", | ||
name => "mongodb-${instance}", | ||
ensure => 'running', | ||
hasstatus => 'true', # this need to be true | ||
provider => 'init', | ||
require => File["sedue::${instance}_mongodb_init_script"] | ||
sedue::server_process { "sedue::${instance}::mongodb::process": | ||
instance => $instance, | ||
server_type => 'mongodb', | ||
run => $run, | ||
require => Sedue::Mongodb_script["sedue::${instance}::mongodb::script"] | ||
} | ||
} else { | ||
service { "sedue::${instance}_mongodb_process": | ||
path => "${sedue_home}/etc/init.d/", | ||
name => "mongodb-${instance}", | ||
ensure => 'stopped', | ||
hasstatus => 'true', # this need to be true | ||
provider => 'init' | ||
} | ||
|
||
file { "sedue::${instance}_mongodb_init_script": | ||
path => "${sedue_home}/etc/init.d/mongodb-${instance}", | ||
ensure => 'absent', | ||
require => Service["sedue::${instance}_mongodb_process"] | ||
} | ||
|
||
# remove all unnecessary files | ||
file { "sedue::${instance}_mongodb_run_symlink": | ||
path => "${sedue_home}/etc/serve/${instance}/mongodb/run", | ||
ensure => 'absent', | ||
require => File["${instance}_serve_directory"] | ||
} | ||
|
||
file { "sedue::${instance}_mongodb_run_directory": | ||
path => "${sedue_home}/etc/serve/${instance}/mongodb", | ||
ensure => 'absent', | ||
force => true, # to remove dir/control, dir/stat | ||
require => File["sedue::${instance}_mongodb_run_symlink"] | ||
} | ||
|
||
file { "sedue::${instance}_mongodb_run_file": | ||
path => "${sedue_home}/etc/serve/${instance}/mongodb.run", | ||
ensure => 'absent', | ||
require => File["sedue::${instance}_mongodb_run_directory"] | ||
# stop process and then delete script | ||
sedue::server_process { "sedue::${instance}::mongodb::process": | ||
instance => $instance, | ||
server_type => 'mongodb', | ||
run => $run | ||
} | ||
|
||
sedue::mongodb_script { "sedue::${instance}::mongodb::script": | ||
user => $user, | ||
instance => $instance, | ||
port => $port, | ||
pair => $pair, | ||
run => $run, | ||
require => Sedue::Server_process["sedue::${instance}::mongodb::process"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# sedue::mongodb assumes sedue::supervise already called | ||
|
||
define sedue::mongodb_script($user, $instance, $port, $pair, $run) { | ||
if $run { | ||
$server_sleep_interval = 3 | ||
$server_name = 'mongodb' | ||
$server_type = 'db' | ||
$server_script_name = $server_name | ||
|
||
if $pair { | ||
$mongodb_options = "--port ${port} --nohttpinterface --oplogSize 4096 --master --slave --source ${pair} --autoresync --quiet" | ||
} else { | ||
$mongodb_options = "--port ${port} --nohttpinterface --quiet" | ||
} | ||
|
||
# generate files for serve supervise | ||
file { "sedue::${instance}::mongodb::run_file": | ||
path => "${sedue_home}/etc/serve/${instance}/mongodb.run", | ||
owner => $user, | ||
group => $user, | ||
mode => '0755', | ||
content => template("sedue/mongodb.run.erb"), | ||
require => File["${instance}_serve_directory"] | ||
} | ||
|
||
file { "sedue::${instance}::mongodb::run_directory": | ||
path => "${sedue_home}/etc/serve/${instance}/mongodb", | ||
owner => $user, | ||
group => $user, | ||
mode => '0755', | ||
ensure => 'directory', | ||
require => File["${instance}_serve_directory"] | ||
} | ||
|
||
file { "sedue::${instance}::mongodb::run_symlink": | ||
path => "${sedue_home}/etc/serve/${instance}/mongodb/run", | ||
ensure => 'link', | ||
target => "${sedue_home}/etc/serve/${instance}/mongodb.run", | ||
require => [File["sedue::${instance}::mongodb::run_file"], File["sedue::${instance}::mongodb::run_directory"]] | ||
} | ||
|
||
file { "sedue::${instance}::mongodb::init_script": | ||
path => "${sedue_home}/etc/init.d/mongodb-${instance}", | ||
owner => $user, | ||
group => $user, | ||
mode => '0755', | ||
content => template("sedue/server.init.d.erb") | ||
} | ||
} else { | ||
# remove all unnecessary files | ||
file { "sedue::${instance}::mongodb::run_symlink": | ||
path => "${sedue_home}/etc/serve/${instance}/mongodb/run", | ||
ensure => 'absent', | ||
require => File["${instance}_serve_directory"] | ||
} | ||
|
||
file { "sedue::${instance}::mongodb::run_directory": | ||
path => "${sedue_home}/etc/serve/${instance}/mongodb", | ||
ensure => 'absent', | ||
force => true, # to remove dir/control, dir/stat | ||
require => File["sedue::${instance}::mongodb::run_symlink"] | ||
} | ||
|
||
file { "sedue::${instance}::mongodb::run_file": | ||
path => "${sedue_home}/etc/serve/${instance}/mongodb.run", | ||
ensure => 'absent', | ||
require => File["sedue::${instance}::mongodb::run_directory"] | ||
} | ||
|
||
file { "sedue::${instance}::mongodb::init_script": | ||
path => "${sedue_home}/etc/init.d/mongodb-${instance}", | ||
ensure => 'absent', | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters