Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to run Haskell inside a jobe server #83

Closed
SSIvanov19 opened this issue Oct 25, 2024 · 3 comments
Closed

Trying to run Haskell inside a jobe server #83

SSIvanov19 opened this issue Oct 25, 2024 · 3 comments

Comments

@SSIvanov19
Copy link

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:

  • Ubuntu 24.04
  • Using latest version of Jobe (2.0.2)
  • 32 Cores
  • 16 GB of RAM
@trampgeek
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

Enter the following into the UI Parameters field:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants