Skip to content

Commit 8b1ae2d

Browse files
committed
feat(launcher): enable retry option on launcher
1 parent d81f627 commit 8b1ae2d

8 files changed

Lines changed: 64 additions & 11 deletions

File tree

examples/launcher/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
www

examples/launcher/retry.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from trame.app import get_server
2+
from trame.widgets import html
3+
from trame.ui.html import DivLayout
4+
5+
server = get_server()
6+
7+
with DivLayout(server) as layout:
8+
html.Div("App is running")
9+
10+
server.start()
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"configuration": {
3+
"host": "localhost",
4+
"port": 8080,
5+
"endpoint": "paraview",
6+
"content": "www",
7+
"proxy_file": "www/proxy-mapping.txt",
8+
"sessionURL": "ws://${host}:${port}/ws",
9+
"timeout": 50,
10+
"log_dir": "www",
11+
"fields": []
12+
},
13+
"resources": [{ "host": "localhost", "port_range": [9001, 9001] }],
14+
"properties": {},
15+
"apps": {
16+
"trame": {
17+
"cmd": [
18+
"python",
19+
"retry.py",
20+
"--port",
21+
"$port",
22+
"--server",
23+
"--authKey",
24+
"${secret}",
25+
"--timeout",
26+
"2"
27+
],
28+
"ready_line": "App running at"
29+
}
30+
}
31+
}

examples/launcher/run_retry.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export TRAME_CLIENT_TYPE=vue3
2+
3+
rm -rf ./www/
4+
python -m trame.tools.www --client-type "$TRAME_CLIENT_TYPE" --output ./www
5+
python -m wslink.launcher ./retry_launcher.json

vue3-app/package-lock.json

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vue3-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"dependencies": {
1111
"@kitware/vtk.js": "^30.3.2",
12-
"wslink": "^2.1.2"
12+
"wslink": "^2.4.0"
1313
},
1414
"devDependencies": {
1515
"@rushstack/eslint-patch": "^1.1.4",

vue3-app/src/core/wslink/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ function configDecorator(config) {
5656
outputConfig.application =
5757
document.querySelector("html").dataset.appName || outputConfig.application;
5858

59+
// Extract retry from html
60+
outputConfig.launcherRetry = JSON.parse(
61+
document.querySelector("html").dataset.launcherRetry || "[]"
62+
);
63+
5964
const sessionManagerURL =
6065
document.querySelector("html").dataset.sessionManagerUrl ||
6166
outputConfig.sessionManagerURL;

vue3-app/src/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async function start() {
5252

5353
// Handle client/server connection error
5454
function reportWsError(message) {
55-
if (trame) {
55+
if (trame && trame.state) {
5656
console.log("about to replace template", message);
5757
trame.state.set("trame_error_report_msg", message);
5858
let templateName = "trame__template_main";
@@ -77,15 +77,15 @@ async function start() {
7777
console.log("template replaced", trame.state.get(templateName));
7878
} else {
7979
app.unmount();
80-
document.querySelector("#app").innerHTML(message);
80+
document.querySelector("#app").innerHTML = message;
8181
}
8282
}
8383

8484
// Connect client to server
8585
try {
8686
config = await trame.connect(config);
8787
} catch (e) {
88-
reportWsError("try/catch on connect()");
88+
reportWsError(e?.response?.error || "try/catch on connect()");
8989
return;
9090
}
9191

0 commit comments

Comments
 (0)