@intuned/runtime-dev 1.1.6-vnc.2 → 1.1.6-vnc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -246,6 +246,20 @@ if (require.main === module) {
246
246
  }
247
247
  const processes = [];
248
248
  async function startVncServer() {
249
+ function listenToProcess(process, name) {
250
+ process.stdout?.on("data", data => {
251
+ console.log(`[${name} ]${data}`);
252
+ });
253
+ process.stderr?.on("data", data => {
254
+ console.error(`[${name}-E]${data}`);
255
+ });
256
+ process.on("error", error => {
257
+ console.error(`${name} error: ${error}`);
258
+ });
259
+ process.on("exit", (code, signal) => {
260
+ console.log(`${name} exited with code ${code} and signal ${signal}`);
261
+ });
262
+ }
249
263
  try {
250
264
  const vncLockPath = "/tmp/.X99-lock";
251
265
  if (await fs.exists(vncLockPath)) {
@@ -258,40 +272,51 @@ async function startVncServer() {
258
272
  } catch (error) {
259
273
  console.error("Error cleaning up VNC locks:", error);
260
274
  }
261
- const openboxProcess = (0, _child_process.spawn)("openbox");
275
+ console.log("Starting VNC server...");
276
+ console.log("Spawning openbox");
277
+ const noDisplayEnv = {
278
+ ...process.env,
279
+ DISPLAY: null
280
+ };
281
+ const openboxProcess = (0, _child_process.spawn)("openbox", {
282
+ env: noDisplayEnv
283
+ });
284
+ listenToProcess(openboxProcess, "openbox");
262
285
  processes.push(openboxProcess);
263
- const devilspieProcess = (0, _child_process.spawn)("devilspie");
286
+ console.log("Spawning devilspie");
287
+ const devilspieProcess = (0, _child_process.spawn)("devilspie", {
288
+ env: noDisplayEnv
289
+ });
290
+ listenToProcess(devilspieProcess, "devilspie");
264
291
  processes.push(devilspieProcess);
265
- const xSetRootProcess = (0, _child_process.spawn)("xsetroot", ["-solid", "#000000"]);
292
+ console.log("Spawning xsetroot");
293
+ const xSetRootProcess = (0, _child_process.spawn)("xsetroot", ["-solid", "#000000"], {
294
+ env: noDisplayEnv
295
+ });
296
+ listenToProcess(xSetRootProcess, "xsetroot");
266
297
  processes.push(xSetRootProcess);
298
+ console.log("Setting up vnc startup script");
267
299
  const vncStartupScript = "exec xclock -digital -update 0 -bg black";
268
300
  await fs.writeFile("/tmp/vnc_startup.sh", vncStartupScript, {
269
301
  mode: 0o755
270
302
  });
303
+ console.log("Spawning vncserver");
271
304
  const vncServerProcess = (0, _child_process.spawn)("vncserver", [":99", "-localhost", "yes", "-rfbauth", "/root/vnc/passwd", "-rfbport", "5900", "-geometry", "1280x720"]);
305
+ listenToProcess(vncServerProcess, "vncserver");
272
306
  processes.push(vncServerProcess);
307
+ console.log("Waiting for VNC server to start...");
273
308
  while (true) {
274
309
  if (await fs.exists("/tmp/.X11-unix/X99")) {
275
310
  break;
276
311
  }
312
+ console.log("VNC server not ready yet, waiting...");
277
313
  await (0, _promises.setTimeout)(1000);
278
314
  }
315
+ console.log("VNC server started successfully");
316
+ console.log("Spawning noVNC server...");
279
317
  const noVncProcess = (0, _child_process.spawn)("/opt/bin/noVNC/utils/launch.sh", ["--listen", "6080", "--vnc", "localhost:5900"]);
318
+ listenToProcess(noVncProcess, "noVNC");
280
319
  processes.push(noVncProcess);
281
- for (const process of processes) {
282
- process.stdout?.on("data", data => {
283
- console.log(`Process ${process.pid} stdout: ${data}`);
284
- });
285
- process.stderr?.on("data", data => {
286
- console.error(`Process ${process.pid} stderr: ${data}`);
287
- });
288
- process.on("error", error => {
289
- console.error(`Process ${process.pid} error: ${error}`);
290
- });
291
- process.on("exit", (code, signal) => {
292
- console.log(`Process ${process.pid} exited with code ${code} and signal ${signal}`);
293
- });
294
- }
295
320
  }
296
321
  async function stopVncServer() {
297
322
  for (const process of processes.reverse()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intuned/runtime-dev",
3
- "version": "1.1.6-vnc.2",
3
+ "version": "1.1.6-vnc.4",
4
4
  "description": "Intuned runtime",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",