1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

v watch: allow customising the auto-restart timeout for the workers with an env variable VWATCH_TIMEOUT

This commit is contained in:
Delyan Angelov 2021-06-19 16:51:40 +03:00
parent 6171e12f9f
commit 3b5a37628f
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 14 additions and 3 deletions

View File

@ -5,7 +5,7 @@ import time
import term
import flag
const scan_timeout_s = 5 * 60
const scan_timeout_s = get_scan_timeout_seconds()
const max_v_cycles = 1000
@ -15,8 +15,16 @@ const scan_period_ms = 1000 / scan_frequency_hz
const max_scan_cycles = scan_timeout_s * scan_frequency_hz
fn get_scan_timeout_seconds() int {
env_vw_timeout := os.getenv('VWATCH_TIMEOUT').int()
if env_vw_timeout == 0 {
return 5 * 60
}
return env_vw_timeout
}
//
// Implements `v -watch file.v` , `v -watch run file.v` etc.
// Implements `v watch file.v` , `v watch run file.v` etc.
// With this command, V will collect all .v files that are needed for the
// compilation, then it will enter an infinite loop, monitoring them for
// changes.
@ -25,7 +33,7 @@ const max_scan_cycles = scan_timeout_s * scan_frequency_hz
// still running, then rerun/recompile/etc.
//
// In effect, this makes it easy to have an editor session and a separate
// terminal, running just `v -watch run file.v`, and you will see your
// terminal, running just `v watch run file.v`, and you will see your
// changes right after you save your .v file in your editor.
//
//

View File

@ -23,3 +23,6 @@ Options:
--after <string> A command to execute *after* each re-run. Example: --after 'rm -rf /tmp/v/'
You can also customise the timeout, after `v watch` will re-start a monitored
program automatically, even if it was not changed by setting the enviroment
variable VWATCH_TIMEOUT (in seconds). By default, it is 5 min. (300 seconds).