woodglue.apps.ui_process¶
Supervising the processes behind Process-backed UIs.
Supervising the processes behind Process-backed UIs.
For each UI with kind or command (see woodglue.config.UiEntry),
UiProcesses runs the process on a free loopback port and keeps it running:
- Started by
wgl startafter the engines, and stopped (SIGTERM, then SIGKILL after a grace period) with them. - Ready once an HTTP request to
ready_pathgets any non-5xx answer; until then the proxy answers 503. - Restarted after it exits, waiting 1s, 2s, 4s, ... up to a minute between
attempts; the wait resets once a run has stayed up for a minute. While it is
down its state is
failed, whichsystem.list_uisreports. - Its stdout and stderr go to the log as
woodglue.ui.<name>.
The process environment adds the UI's env and WOODGLUE_URL, the loopback
address of the woodglue API.
An upstream UI has no process; UiProcesses.upstream returns its URL as is.
UiProcess
¶
One supervised UI process across its restarts.
Source code in src/woodglue/apps/ui_process.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
UiProcesses
¶
The supervised processes and upstream URLs of all Process-backed UIs.
Source code in src/woodglue/apps/ui_process.py
upstream(name)
¶
Where to proxy a UI's requests now, or None while its process is not ready.
Source code in src/woodglue/apps/ui_process.py
ui_command(name, entry, port)
¶
The command line for a supervised UI.
>>> e = UiEntry(command=["srv", "--port={port}", "--root={base_path}"])
>>> ui_command("dash", e, 8601)
['srv', '--port=8601', '--root=/ui/dash']
>>> cmd = ui_command("dash", UiEntry(kind="streamlit", app="app.py"), 8601)
>>> cmd[1:5], cmd[5:8]
(['-m', 'streamlit', 'run', 'app.py'], ['--server.port=8601', '--server.address=127.0.0.1', '--server.baseUrlPath=ui/dash'])
Source code in src/woodglue/apps/ui_process.py
ready_path(name, entry)
¶
>>> ready_path("dash", UiEntry(kind="streamlit", app="a.py"))
'/ui/dash/_stcore/health'
>>> ready_path("x", UiEntry(command=["srv"]))
'/ui/x/'