Skip to content

Commit 32ce3d9

Browse files
committed
tools: make fast_job.v more robust
1 parent edb3f1d commit 32ce3d9

File tree

1 file changed

+37
-15
lines changed

1 file changed

+37
-15
lines changed

cmd/tools/fast/fast_job.v

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,66 @@
44
import os
55
import time
66

7+
const vexe = @VEXE
8+
9+
const sleep_period = 120
10+
711
fn elog(msg string) {
812
eprintln('$time.now().format_ss_micro() $msg')
913
}
1014

15+
fn delay() {
16+
elog('Sleeping for $sleep_period seconds...')
17+
time.sleep(sleep_period * time.second)
18+
}
19+
1120
// A job that runs in the background, checks for repo updates,
1221
// runs fast.v, pushes the HTML result to the fast.vlang.io GH pages repo.
1322
fn main() {
14-
elog('fast_job start')
23+
os.chdir(os.dir(@FILE))!
24+
os.setenv('LANG', 'C', true)
25+
elog('fast_job start in os.getwd(): $os.getwd()')
1526
defer {
1627
elog('fast_job end')
1728
}
29+
1830
if !os.exists('website') {
1931
println('cloning the website repo...')
2032
os.system('git clone git@github.com:/vlang/website.git')
2133
}
22-
if !os.exists('fast') {
23-
println('"fast" binary (built with `v fast.v`) was not found')
24-
return
25-
}
2634
for {
27-
eprintln('$time.now().format_ss_micro() checking for updates ...')
35+
elog('------------------- Checking for updates ... -------------------')
2836
res_pull := os.execute('git pull --rebase')
2937
if res_pull.exit_code != 0 {
3038
println('failed to git pull. uncommitted changes?')
31-
return
39+
println('res_pull.output: $res_pull.output')
40+
delay()
41+
continue
42+
}
43+
if res_pull.output.contains('Already up to date.') {
44+
if os.args[1] or { '' } == '-force-update' {
45+
elog('The repository was already updated, but -force-update was passed too.')
46+
} else {
47+
elog('Already updated.')
48+
delay()
49+
continue
50+
}
3251
}
33-
// println('running ./fast')
52+
53+
elog('recompiling V')
54+
os.system('${os.quoted_path(vexe)} self')
55+
56+
elog('recompiling ./fast')
57+
os.execute('${os.quoted_path(vexe)} fast.v')
58+
os.system('ls -la fast fast.v')
59+
3460
elog('running ./fast -upload')
3561
resp := os.execute('./fast -upload')
36-
if resp.exit_code < 0 {
37-
println(resp.output)
38-
return
39-
}
4062
if resp.exit_code != 0 {
41-
println('resp != 0, skipping')
63+
println('resp.exit_code = $resp.exit_code != 0')
4264
println(resp.output)
4365
}
44-
elog('sleeping for 180 seconds...')
45-
time.sleep(180 * time.second)
66+
67+
delay()
4668
}
4769
}

0 commit comments

Comments
 (0)