mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-07-11 23:32:56 +02:00
Pass host environment variable to plugin runtime
https://feedback.yaak.app/p/when-i-use-clash-yaak-fails-to-launch
This commit is contained in:
@@ -8,10 +8,15 @@ if (!port) {
|
|||||||
throw new Error('Plugin runtime missing PORT')
|
throw new Error('Plugin runtime missing PORT')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const host = process.env.HOST;
|
||||||
|
if (!host) {
|
||||||
|
throw new Error('Plugin runtime missing HOST')
|
||||||
|
}
|
||||||
|
|
||||||
const pluginToAppEvents = new EventChannel();
|
const pluginToAppEvents = new EventChannel();
|
||||||
const plugins: Record<string, PluginHandle> = {};
|
const plugins: Record<string, PluginHandle> = {};
|
||||||
|
|
||||||
const ws = new WebSocket(`ws://localhost:${port}`);
|
const ws = new WebSocket(`ws://${host}:${port}`);
|
||||||
|
|
||||||
ws.on('message', async (e: Buffer) => {
|
ws.on('message', async (e: Buffer) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ pub async fn start_nodejs_plugin_runtime<R: Runtime>(
|
|||||||
let cmd = app
|
let cmd = app
|
||||||
.shell()
|
.shell()
|
||||||
.sidecar("yaaknode")?
|
.sidecar("yaaknode")?
|
||||||
|
.env("HOST", addr.ip().to_string())
|
||||||
.env("PORT", addr.port().to_string())
|
.env("PORT", addr.port().to_string())
|
||||||
.args(&[&plugin_runtime_main]);
|
.args(&[&plugin_runtime_main]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user