Remove interval once the website loads
This commit is contained in:
parent
ae54c490d5
commit
f3398708ee
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
||||||
/node_modules/
|
/node_modules/
|
||||||
/static/
|
/static/
|
||||||
|
/.log/
|
||||||
|
/yarn-error.log
|
||||||
|
|
|
@ -83,6 +83,7 @@ prepare_firefox(){
|
||||||
keycombo Shift_L F5 #profiler
|
keycombo Shift_L F5 #profiler
|
||||||
grab "after shift-c F5"
|
grab "after shift-c F5"
|
||||||
keycombo Control_L Shift_L e
|
keycombo Control_L Shift_L e
|
||||||
|
sleep 5 # it needs some time
|
||||||
}
|
}
|
||||||
|
|
||||||
load_website(){
|
load_website(){
|
||||||
|
|
25
index.js
25
index.js
|
@ -32,23 +32,12 @@ function attach(docker_id, output_stream) {
|
||||||
output_stream.push(d);
|
output_stream.push(d);
|
||||||
});
|
});
|
||||||
task.on("close", () => {
|
task.on("close", () => {
|
||||||
const check = spawn("docker", ["ps", "--filter", `id=${docker_id}`]);
|
output_stream.push("</pre>");
|
||||||
let output = "";
|
output_stream.push(/* HTML */ `<script>
|
||||||
check.on("data", (data) => {
|
clearInterval(window.interval);
|
||||||
output += data;
|
</script>`);
|
||||||
});
|
clearInterval(interval);
|
||||||
check.on("close", () => {
|
output_stream.push(null);
|
||||||
console.log("CHECK", output);
|
|
||||||
clearInterval(interval);
|
|
||||||
});
|
|
||||||
check.on("error", (error) => {
|
|
||||||
console.error("error", error);
|
|
||||||
clearInterval(interval);
|
|
||||||
});
|
|
||||||
check.on("exit", (error) => {
|
|
||||||
console.error("exit", error);
|
|
||||||
clearInterval(interval);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +53,7 @@ router.get("/", async (ctx) => {
|
||||||
`<img id="preview" width="1080" height="608" src="/static/${id}/preview.png?id=0"/><br/>`
|
`<img id="preview" width="1080" height="608" src="/static/${id}/preview.png?id=0"/><br/>`
|
||||||
);
|
);
|
||||||
ctx.body.push(/* HTML */ `<script>
|
ctx.body.push(/* HTML */ `<script>
|
||||||
setInterval(() => (preview.src = preview.src + "0"), 500);
|
window.interval = setInterval(() => (preview.src = preview.src + "0"), 500);
|
||||||
</script>`);
|
</script>`);
|
||||||
const params = qs.parse(ctx.querystring);
|
const params = qs.parse(ctx.querystring);
|
||||||
s.push(`Got request to screenshot ${params.url}<pre>`);
|
s.push(`Got request to screenshot ${params.url}<pre>`);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user