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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! The daemon, as the command line sees it.
//!
//! wsb is two programs. `wsb` is a command line that starts, does one thing
//! and exits; `wsb-daemon` is a process that stays and serves the workbench.
//! This module is everything the first needs to find, start and talk to the
//! second — the REST contract they share, the files they meet at, and the
//! rules about which daemon is the right one to talk to.
//!
//! # Why a daemon at all
//!
//! A command line cannot serve the workbench, which has to outlive whatever
//! started it or somebody has to keep a terminal open for it. The daemon also
//! keeps the machine's GitHub mirror current and carries peer continuity.
//!
//! # What the daemon is not
//!
//! It is not a place work happens. Commands still do their own work in their
//! own process; the daemon hosts the workbench. `--no-daemon` therefore loses
//! the workbench and changes nothing about what a command does.
//!
//! # One daemon, one MACHINE
//!
//! The daemon serves every worktree on this machine, from one process at one
//! port, with its state in the machine directory (see [`machine`]). It was one
//! daemon per checkout, and that made a machine with six checkouts run six
//! daemons, bind six ports and hold six copies of everything — and left peer
//! identity, which is a property of the MACHINE, with nowhere to live.
pub use Client;
pub use ;
pub use ;
pub use ;
pub use Rendezvous;
/// Saying "no daemon" to every wsb in a run, not just the first.
///
/// `--no-daemon` sets it, and every wsb started underneath reads it. Without
/// that, a command told to stay in one process would have children starting
/// daemons behind it — and the operator would find one running after a run
/// they explicitly asked to keep local.
///
/// It is also how a test harness declares that it must not touch this
/// machine's daemon: the suites drive wsb against fixture workspaces, and a
/// daemon started there would outlive the temporary directory it was serving.
pub const NO_DAEMON_ENV: &str = "WSB_NO_DAEMON";
/// Whether this run has been told to keep to itself.
///
/// One reading of the variable, so "does this run use the daemon" is one
/// question with one answer rather than a condition each caller writes out.
/// Where a daemon listens unless somebody says otherwise.
///
/// This machine and nothing else. The workbench has no authentication — it
/// reads and edits the workspace and runs git on it — so who can reach
/// it is a decision an operator makes deliberately, per start, with
/// `wsb serve --listen`. It is
/// not a stored preference: a daemon that came back up reachable because of
/// something switched on months ago is the failure this default exists to
/// prevent.
pub const LOOPBACK: IpAddr = V4;
/// The default port the workbench is served on.
///
/// Where an unnamed port STARTS. A daemon told to take an exact port and
/// finding it held says so and stops; one that was not told takes the first
/// free port from here and publishes it, because the alternative is that the
/// second workspace on a machine can never have a daemon at all.
pub const DEFAULT_HTTP_PORT: u16 = 3000;