-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp_service
executable file
·52 lines (40 loc) · 1.2 KB
/
app_service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env perl
use warnings;
use strict;
use Daemon::Control;
use ENV::Util -load_dotenv;
use Cwd qw(abs_path);
use File::Basename;
my $abs_path = abs_path($0);
my $abs_dir = dirname($0);
my @vars = qw[USER PASS HOST NAME];
if (grep { ! defined $ENV{"SUCC_DB_$_"} } @vars) {
die "Please define the DB connection variables: SUCC_DB*\n";
}
my @program_args;
if ($ENV{SUCC_WORKER_COUNT}) {
push @program_args, '--workers', $ENV{SUCC_WORKER_COUNT};
}
if ($ENV{SUCC_APP_PORT}) {
push @program_args, '-l', ":$ENV{SUCC_APP_PORT}";
}
if ($ENV{SUCC_APP_PRELOAD}) {
push @program_args, '--preload-app';
}
push @program_args, "$abs_dir/Succession/bin/app.psgi";
Daemon::Control->new({
name => ucfirst lc $ENV{SUCC_APP_NAME},
lsb_start => '$syslog $remote_fs',
lsb_stop => '$syslog',
lsb_sdesc => 'British Line of Succession',
lsb_desc => 'British Line of Succession',
path => $abs_path,
program => '/usr/bin/starman',
program_args => \@program_args,
user => $ENV{SUCC_OWNER},
group => $ENV{SUCC_GROUP},
pid_file => "/var/run/$ENV{SUCC_APP_NAME}.pid",
stderr_file => "$ENV{SUCC_LOG_DIR}/error.log",
stdout_file => "$ENV{SUCC_LOG_DIR}/output.log",
fork => 2,
})->run;