Commit 50502035c4665cc91a1f769df4cc48c33cf3a20e
1 parent
cd07811d
Exists in
master
Add start script
There is a util/start.pl script to be called by the systemd unit which will fork to update data and start plack.
Showing
3 changed files
with
27 additions
and
21 deletions
Show diff stats
copr_status.service
@@ -3,7 +3,7 @@ Description=Copr Status | @@ -3,7 +3,7 @@ Description=Copr Status | ||
3 | After=network.target | 3 | After=network.target |
4 | 4 | ||
5 | [Service] | 5 | [Service] |
6 | -ExecStart=/usr/bin/plackup -Ilib | 6 | +ExecStart=/usr/bin/perl -Ilib util/start.pl |
7 | WorkingDirectory=path/to/copr-status | 7 | WorkingDirectory=path/to/copr-status |
8 | Restart=on-failure | 8 | Restart=on-failure |
9 | 9 |
@@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
1 | +use CoprStatus; | ||
2 | +use YAML::XS 'LoadFile'; | ||
3 | + | ||
4 | +my $config = LoadFile('config.yaml'); | ||
5 | + | ||
6 | +sub update_files { | ||
7 | + while(1) { | ||
8 | + my $user = $config->{User}; | ||
9 | + my $repo_index = 0; | ||
10 | + foreach my $branch (@{$config->{Branches}}) { | ||
11 | + CoprStatus::download_specs($branch, $user, ${$config->{Repositories}}[$repo_index]); | ||
12 | + $repo_index += 1; | ||
13 | + } | ||
14 | + | ||
15 | + sleep $config->{UpdateRate}; | ||
16 | + } | ||
17 | +} | ||
18 | + | ||
19 | +my $child_pid = fork(); | ||
20 | +if($child_pid) { | ||
21 | + update_files(); | ||
22 | + exit(0); | ||
23 | +} | ||
24 | + | ||
25 | +system("plackup -Ilib"); | ||
26 | + |
util/update_files.pl
@@ -1,20 +0,0 @@ | @@ -1,20 +0,0 @@ | ||
1 | -use CoprStatus; | ||
2 | -use YAML::XS 'LoadFile'; | ||
3 | - | ||
4 | -my $config = LoadFile('config.yaml'); | ||
5 | - | ||
6 | -sub update_files { | ||
7 | - while(1) { | ||
8 | - my $user = $config->{User}; | ||
9 | - my $repo_index = 0; | ||
10 | - foreach my $branch (@{$config->{Branches}}) { | ||
11 | - CoprStatus::download_specs($branch, $user, ${$config->{Repositories}}[$repo_index]); | ||
12 | - $repo_index += 1; | ||
13 | - } | ||
14 | - | ||
15 | - sleep $config->{UpdateRate}; | ||
16 | - } | ||
17 | -} | ||
18 | - | ||
19 | -update_files(); | ||
20 | - |