trampgeek / jobe

jobe is a server that runs small programming jobs in a variety of programming languages
MIT License
111 stars 80 forks source link

Trying to run Haskell inside a jobe server #83

Closed SSIvanov19 closed 3 weeks ago

SSIvanov19 commented 4 weeks ago

Hello, I am trying to run a Haskell program inside Jobe server, using JS. Here is my script:

const { exec, execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const stream = require('stream');

fs.writeFileSync("prog.hs", `
{{ STUDENT_ANSWER | e('c') }}
`); 

try {
        let res = execSync(`runghc ${cflags} prog.hs`, { env: process.env, stdio: 'inherit' });

        if (res !== null){
            console.log(res.toString('utf8'));
        }
} catch (error){
        console.log(error.message);
}

When I run it on the server using node, the script runs without a problem. But when I submitted it through code runner on Moodle, I get the following error:

Command failed: runghc  prog.hs
ghc: failed to create OS thread: Cannot allocate memory

The server I run it is a VM running:

trampgeek commented 3 weeks ago

Jobe runs tasks with limits on memory and number of processes. You've almost certainly hit the memory limit. This can be set in the question by checking the Customise box and opening the Advanced Configuration section. You'll find a field MemLimit (MB). Setting that to 0 will turn off the memory limit. If that fixes your problem, experiment to find a reasonable upper limit. Don't leave it at 0 or a memory gobbling task can bring down Jobe temporarily - the watchdog timer will kill it, but this could take a while if the machine is thrashing

For more info on such configurations, and screenshots, see https://coderunner.org.nz/mod/forum/discuss.php?d=141.

SSIvanov19 commented 3 weeks ago

I’ve successfully run the program through Code Runner after increasing the memory limit. Now, I’m trying to achieve the same result using Scratchpad, but I can’t find where to adjust the memory limit in Scratchpad. Do you have any ideas on how to do this?

trampgeek commented 3 weeks ago

Enter the following into the UI Parameters field:

{"params": {"memorylimit": 0}}