-
Notifications
You must be signed in to change notification settings - Fork 14
/
Akefile
60 lines (53 loc) · 2.31 KB
/
Akefile
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
53
54
55
56
57
58
59
60
#!/usr/bin/env perl6
my @bots = dir ‘xbin’, test => / ‘able.p6’ $ /;
task ‘help’, {
note ‘Useful commands:’;
note ‘ ake debug:botname (example: 「ake debug:bisectable」)’;
note ‘ ake kill:botname (example: 「ake kill:committable」)’;
note ‘ ake killall’;
note ‘ ake test (run the test suite)’;
note ‘ ake mothership-pull (pulls the current version from the server)’;
}
sub to-name($_) { .extension(‘’).basename }
for @bots -> $file {
my $bot = to-name $file;
task ‘start:’ ~ ( $bot | $bot.lc ), {
note “Starting $bot…”;
my $config = ‘/run/secrets/config’.IO.open || ‘config.json’.IO.open || ‘config-default.json’.IO.open;
run $file, :in($config),
:env(|%*ENV, PERL6LIB => ‘lib’);
True
}
task ‘debug:’ ~ ( $bot | $bot.lc ), {
note “Starting $bot in DEBUG mode…”;
my $config = ‘/run/secrets/config’.IO.open || ‘config.json’.IO.open || ‘config-default.json’.IO.open;
run $file, :in($config),
:env(|%*ENV, PERL6LIB => ‘lib’, DEBUGGABLE => 1);
True
}
task ‘kill:’ ~ ( $bot | $bot.lc ), {
note “Killing $bot…”;
my $pid = run(:out, ‘systemctl’, ‘--property=MainPID’, ‘--’,
‘show’, “whateverable@$bot.service”).out.slurp.trim;
$pid .= subst: /^‘MainPID=’/, ‘’;
run ‘kill’, ‘--’, $pid;
True
}
}
task ‘start-all’, {
note ‘start-all is no longer needed, ’
~ ‘systemd should start (and restart) the bots automatically’;
exit 1
}
task $_ => @bots.map({‘kill:’ ~ to-name $_}), {;} for <kill stop> X~ <-all all>;
task ‘test’, { run <prove -j 8 --exec perl6 xt>; True }
task ‘upgrade’ => ‘stop-all’, { run ‘rakudobrew’, ‘build’, ‘moar’; True }
my $RSYNC = ‘[email protected]:/home/bisectable/git/whateverable/’;
task ‘mothership-pull’, {
run ‘rsync’, ‘--archive’, ‘--verbose’, ‘--fuzzy’, ‘--compress’,
‘--human-readable’,
‘--exclude=data’, ‘--exclude=.git’, ‘--exclude=.precomp’,
$RSYNC, ‘.’;
True
}
# vim: expandtab shiftwidth=4 ft=perl6