-
Notifications
You must be signed in to change notification settings - Fork 19
add a queue init script on dev boxes #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,21 @@ | ||
| # == Class: minion_queue | ||
| # | ||
| # Probably requires metacpan::system::postgress | ||
| # but that's not a specific dependency for now | ||
| # | ||
| # Add the following to hiera | ||
| # | ||
| # classes: | ||
| # - minion_queue | ||
| # | ||
| # minion_queue::service::workers: 1 | ||
| # minion_queue::service::ensure: running | ||
| # minion_queue::service::enable: true | ||
| # | ||
| # | ||
| class minion_queue( | ||
| ) { | ||
|
|
||
| include minion_queue::service | ||
|
|
||
| } |
This file contains hidden or 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,29 @@ | ||
| # Install init script for minion_queue | ||
| # See init.pp for details | ||
| class minion_queue::service ( | ||
| $workers = hiera('minion_queue::service::workers', 1 ), | ||
| $service_ensure = hiera('minion_queue::service::ensure', 'stopped' ), | ||
| $service_enable = hiera('minion_queue::service::enable', false ), | ||
| $user = hiera('metacpan::user', 'metacpan'), | ||
| $group = hiera('metacpan::group', 'metacpan'), | ||
| ) { | ||
| include perl | ||
|
|
||
| $service_name = "minion_queue" | ||
| $perlbin = $perl::params::bin_dir | ||
|
|
||
| $init = "/etc/init.d/${service_name}" | ||
|
|
||
| file { $init: | ||
| ensure => file, | ||
| mode => '0755', | ||
| owner => $user, | ||
| group => $group, | ||
| content => template('minion_queue/init.pl.erb'), | ||
| } | ||
|
|
||
| service { $service_name: | ||
| ensure => $service_enable, | ||
| enable => $service_enable, | ||
| } | ||
| } |
This file contains hidden or 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,65 @@ | ||
| #!<%= @perlbin %>/perl | ||
| <%# vim: set syn=perl.eruby ts=4 sts=4 sw=4 et sta: %> | ||
| # Generated by puppet. | ||
|
|
||
| ### BEGIN INIT INFO | ||
| # Provides: <%= @name %> | ||
| # Required-Start: $all | ||
| # Required-Stop: | ||
| # Default-Start: 2 3 4 5 | ||
| # Default-Stop: 0 1 6 | ||
| # Short-Description: Starts <%= @name %> | ||
| # Description: Starts <%= @name %> | ||
| ### END INIT INFO` | ||
|
|
||
| use strict; | ||
| use warnings; | ||
|
|
||
| use Daemon::Control; | ||
| use File::Path 2.06 (); # core | ||
|
|
||
| my $name = "minion_queue"; | ||
|
|
||
| my $code_base_name = 'metacpan-api'; | ||
|
|
||
| my $user = '<%= @user %>'; | ||
| my $home = "/home/${user}/${code_base_name}"; | ||
|
|
||
| my %dirs = ( | ||
| pid => "$home/var/run", | ||
| log => "$home/var/log", | ||
| ); | ||
| my $carton = '<%= @perlbin %>/carton'; | ||
| my $workers = <%= @workers %>; | ||
|
|
||
| my $carton_dir = "/home/${user}/carton"; | ||
| my $carton_path = "${carton_dir}/${code_base_name}"; | ||
|
|
||
| # TODO: Should we use the ./bin/carton wrapper instead of setting this here? | ||
| $ENV{PERL_CARTON_PATH} = $carton_path; | ||
|
|
||
| # We need the right perl in the ENV | ||
| $ENV{PATH} = '<%= @perlbin %>:' . $ENV{PATH}; | ||
|
|
||
| # carton exec bin/queue.pl | ||
| my @program_args = ( | ||
| 'exec', "${home}/bin/queue.pl", | ||
| 'minion', 'worker', | ||
| '-j', $workers | ||
| ); | ||
|
|
||
| my $args = { | ||
| directory => $home, | ||
| fork => 2, | ||
| group => $user, | ||
| lsb_desc => "Starts $name", | ||
| lsb_sdesc => "Starts $name", | ||
| name => $name, | ||
| pid_file => "$dirs{pid}/${name}.pid", | ||
| program => $carton, | ||
| program_args => \@program_args, | ||
| stderr_file => "$dirs{log}/${name}.log", | ||
| user => $user, | ||
| }; | ||
|
|
||
| exit Daemon::Control->new($args)->run; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine, unless we start doing really fancy things in the wrapper.