Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Daemon::Control script + Carton wrappers.
- Loading branch information
Showing
5 changed files
with
60 additions
and
0 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 |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
*.kpf | ||
*.komodoproject | ||
*.sqlite* | ||
/var/logs/ | ||
/var/run/ | ||
/var/tmp/ | ||
/var/log/metacpan.* | ||
/t/var/tmp/ | ||
|
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,4 +1,5 @@ | ||
[PerlTidy] | ||
select = {lib,t}/**/*.{pl,pm,t,psgi} | ||
select = bin/daemon-control.pl | ||
select = app.psgi | ||
ignore = t/var/**/* |
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,2 @@ | ||
#!/bin/sh | ||
carton exec perl -Ilib $@ |
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,52 @@ | ||
#!/usr/local/perlbrew/perls/perl-5.16.2/bin/perl | ||
|
||
# usage: perl bin/daemon_control.pl get_init_file > /path/to/init/script | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Daemon::Control; | ||
use Sys::Hostname qw( hostname ); | ||
|
||
my $name = 'metacpan-api'; | ||
my $user = 'metacpan'; | ||
my $home = '/home/metacpan/api.metacpan.org'; | ||
my $carton = '/usr/local/perlbrew/perls/perl-5.16.2/bin/carton'; | ||
my $workers = 10; | ||
|
||
if ( hostname() eq 'debian' ) { | ||
$user = 'vagrant'; | ||
$workers = 3; | ||
} | ||
|
||
my @program_args = ( | ||
'exec', '/usr/local/perlbrew/perls/perl-5.16.2/bin/plackup', | ||
'--port' => 5000, | ||
'--workers' => $workers, | ||
'-E' => 'production', | ||
'-Ilib', | ||
'-a' => 'app.psgi', | ||
'-s', => 'Starman', | ||
); | ||
|
||
# Notes on unused args | ||
# scan_name: seems to be just 'starman master' (not useful) | ||
# stdout_file: always seems to be just empty | ||
|
||
my $args = { | ||
directory => $home, | ||
fork => 2, | ||
group => $user, | ||
init_config => "$home/.metacpanrc", | ||
lsb_desc => "Starts $name", | ||
lsb_sdesc => "Starts $name", | ||
name => $name, | ||
path => "$home/bin/daemon-control.pl", | ||
pid_file => "$home/var/run/$name.pid", | ||
program => $carton, | ||
program_args => \@program_args, | ||
stderr_file => "$home/var/logs/starman_error.log", | ||
user => $user, | ||
}; | ||
|
||
Daemon::Control->new($args)->run; |
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,3 @@ | ||
#!/bin/sh | ||
|
||
carton exec prove -lv $@ |