You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just came up with a somewhat crude implementation for a simple REST server for neu.
Following up on #315 I realized that both execCommand and spawnProcess won't terminate their respective processes when the app exits. So I kill a named process on startup and app.exit.
Example server code for nodejs (test-server.js):
var http = require('http');
var server = http.createServer(function (request, response) {
response.writeHead(200, { "Content-Type": "text\plain" });
if (request.method == "GET") {
let r = parseInt(Math.random() * 100)
response.end("GET request: " + r)
} else {
response.end("Undefined request.");
}
});
server.listen(8000);
console.log("Server running on port 8000");
Minimal neu code (minimal.js in index.html)
let process_cmd = "node test-server.js"
async function onWindowClose() {
kill_process()
Neutralino.app.exit();
}
Neutralino.init();
Neutralino.events.on("windowClose", onWindowClose);
let kill_process = async () => {
let temp = await Neutralino.os.execCommand(`pkill -xf '${process_cmd}'`);
}
let start = async () => {
kill_process()
let proc = await Neutralino.os.spawnProcess(process_cmd);
}
start()
This discussion was converted from issue #1171 on November 25, 2023 11:09.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I just came up with a somewhat crude implementation for a simple REST server for neu.
Following up on #315 I realized that both execCommand and spawnProcess won't terminate their respective processes when the app exits. So I kill a named process on startup and app.exit.
Example server code for nodejs (test-server.js):
Minimal neu code (minimal.js in index.html)
Hope that makes sense and helps someone.
Cheers, Dirk
Beta Was this translation helpful? Give feedback.
All reactions