Jump to content

elevatecore

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by elevatecore

  1. Just to summarize, the bottom line is I can't run shot-lived JavaScript via PHP. But I can run dedicated node+express (app.js) on dedicated port (ex:3000) 24/7, which will use memory and CPU and may hit the daily limit, is that right?
  2. I know it can be done with PHP/perl, I stopped coding in PHP/Perl for more than a decade now. I wanted to use JS tech stack to demonstrate for the workshop that I conduct, And I have many light-weight JS APIs, that don't want rewrite in PHP/Perl/Python now. BTW, what version of python is available? I prefer to use 3.12+ --- const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); const randomCPU = () => parseFloat((Math.random() * 100).toFixed(1)); const randomStatus = (cpu) => cpu > 80 ? "warning" : "healthy"; export default async function* serve(request) { let length = parseInt(request.query_string?._length || 10, 10); if (isNaN(length) || length < 1) length = 1; if (length > 100) length = 100; for (let i = 1; i <= length; i++) { await sleep(100); const cpu = randomCPU(); yield { chunk_id: i, event: "telemetry_pulse", timestamp: new Date().toISOString(), metrics: { cpu_utilization: cpu, memory_free_bytes: Math.floor(Math.random() * 1000000) + 10000000, status: randomStatus(cpu) }, engine: "ES Modules (.mjs)" }; } } Just FYR. This JS generates max 100 dynamic streaming records, which will be consumed in browser UI to plot a graph or table or list...
  3. I want to generate some mock data for my demo/workshop using node (javascipt) json. I don't want to run a dedicated node+express server wasting server resources like memory/cpu. These mock api calls will be called only during a workshop/demo otherwise there is no need of this service. So I have written a simple javascript to generate random json payload based on the request type. that I want to execute through simple php-node.php router where I will use shell_exec to run the node script on demand and it ends the request. Want to keep it simple and efficient on-demand execution instead of running a service forever on a different port. that causes CORS issue as well. Do you have a better alternate solution?
  4. Thanks for the info. This helps to some extent. I don't want run node app as service on any dedicated port. I want to execute a short-lived javascript like node getuser.js under (php shell_exec / popen) but I see my php configuration: disable_functions:opcache_get_status,exec,passthru,proc_nice,proc_open,shell_exec,system,popen,pcntl_exec I don't want to run any service forever, just use node based code to run per request and exit. How can I do that? Thanks in advance.
  5. I wanted to know the details of the server, installed software version, disk space usage in my space, etc. like uname -os ldd --version python --version node -v du -sh * du -sh .[^.]*
  6. Hi, I just signed up for hosting and checking for SSH Terminal access, but the dashboard shows it is forbidden. How to enable? Thanks Kumar
×
×
  • Create New...