mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 17:18:32 +02:00
Fix plugin runtime port
This commit is contained in:
@@ -3,7 +3,10 @@ import { EventChannel } from './EventChannel';
|
|||||||
import { PluginHandle } from './PluginHandle';
|
import { PluginHandle } from './PluginHandle';
|
||||||
import WebSocket from 'ws';
|
import WebSocket from 'ws';
|
||||||
|
|
||||||
const port = process.env.YAAK_PLUGIN_SERVER_PORT || '9442';
|
const port = process.env.PORT;
|
||||||
|
if (!port) {
|
||||||
|
throw new Error('Plugin runtime missing PORT')
|
||||||
|
}
|
||||||
|
|
||||||
const events = new EventChannel();
|
const events = new EventChannel();
|
||||||
const plugins: Record<string, PluginHandle> = {};
|
const plugins: Record<string, PluginHandle> = {};
|
||||||
@@ -17,9 +20,9 @@ ws.on('message', async (e: Buffer) => {
|
|||||||
console.log('Failed to handle incoming plugin event', err);
|
console.log('Failed to handle incoming plugin event', err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ws.on('open', (e) => console.log('Plugin runtime connected to websocket', e));
|
ws.on('open', () => console.log('Plugin runtime connected to websocket'));
|
||||||
ws.on('error', (e) => console.error('Plugin runtime websocket error', e));
|
ws.on('error', (err: any) => console.error('Plugin runtime websocket error', err));
|
||||||
ws.on('close', (e) => console.log('Plugin runtime websocket closed', e));
|
ws.on('close', (code: number) => console.log('Plugin runtime websocket closed', code));
|
||||||
|
|
||||||
// Listen for incoming events from plugins
|
// Listen for incoming events from plugins
|
||||||
events.listen((e) => {
|
events.listen((e) => {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ pub async fn start_nodejs_plugin_runtime<R: Runtime>(
|
|||||||
let cmd = app
|
let cmd = app
|
||||||
.shell()
|
.shell()
|
||||||
.sidecar("yaaknode")?
|
.sidecar("yaaknode")?
|
||||||
.env("YAAK_PLUGIN_RUNTIME_PORT", addr.port().to_string())
|
.env("PORT", addr.port().to_string())
|
||||||
.args(&[&plugin_runtime_main]);
|
.args(&[&plugin_runtime_main]);
|
||||||
|
|
||||||
let (mut child_rx, child) = cmd.spawn()?;
|
let (mut child_rx, child) = cmd.spawn()?;
|
||||||
|
|||||||
Reference in New Issue
Block a user