v watch: allow customising the auto-restart timeout for the workers with an env variable VWATCH_TIMEOUT
parent
6171e12f9f
commit
3b5a37628f
|
@ -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.
|
||||
//
|
||||
//
|
||||
|
|
|
@ -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).
|
||||
|
|
Loading…
Reference in New Issue