Topic on Talk:Parsoid

Error when starting the server.js

16
Summary by Arlolra

Parsoid starts os.cpus().length workers by default, which may be a lot on shared hosting. Limit it with the -n flag

MagaFun (talkcontribs)

I ran the command node bin/server.js and it gives me such error:

{"name":"parsoid","hostname":"cp-hk-1.webhostbox.net","pid":279063,"level":60,"err":{"message":"spawn ENOMEM","name":"Error","stack":"Error: spawn ENOMEM\n    at exports._errnoException (util.js:1022:11)\n    at ChildProcess.spawn (internal/child_process.js:313:11)\n    at exports.spawn (child_process.js:385:9)\n    at exports.fork (child_process.js:63:10)\n    at createWorkerProcess (cluster.js:321:12)\n    at EventEmitter.cluster.fork (cluster.js:356:27)\n    at Master._startWorkers (/home/ahysprkj/parsoid/node_modules/service-runner/lib/master.js:200:30)\n    at Worker.<anonymous> (/home/ahysprkj/parsoid/node_modules/service-runner/lib/master.js:267:38)\n    at emitTwo (events.js:111:20)\n    at Worker.emit (events.js:191:7)\n    at ChildProcess.Worker.process.on (cluster.js:54:12)\n    at emitTwo (events.js:106:13)\n    at ChildProcess.emit (events.js:191:7)\n    at process.nextTick (internal/child_process.js:752:12)\n    at _combinedTickCallback (internal/process/next_tick.js:67:7)\n    at process._tickCallback (internal/process/next_tick.js:98:9)","code":"ENOMEM","errno":"ENOMEM","syscall":"spawn","levelPath":"fatal/service-runner/unhandled"},"msg":"spawn ENOMEM","time":"2016-12-01T11:53:28.886Z","v":0}

Is there a way to solve this? Thanks in advance.

This post was hidden by MagaFun (history)
Arlolra (talkcontribs)

ENOMEM is the out of memory error. What does free -m say? Is swap enabled?

There's a way to restrict the heap in node.js, with the --max-old-space-size flag. You could try that.

MagaFun (talkcontribs)

total       used       free     shared    buffers     cached

Mem:         23929      22629       1299         65       2874       6427

-/+ buffers/cache:      13327      10602

Swap:         4095       2956       1139

The output is above.

Arlolra (talkcontribs)

I think node's default heap size ~2 GB and you've 1299 MB free. You might want to try to free up some RAM.

Alternatively, you can run with the above flag, --max-old-space-size

Or, reduce the number of workers Parsoid is launching. The default should be the same as the number of cpus on your machine. But try with 1 or 0, even, which will forgo the master (but that presents other challenges).

node --max-old-space-size=128 bin/server.js -n 1

This post was hidden by MagaFun (history)
MagaFun (talkcontribs)

{"name":"parsoid","hostname":"cp-hk-1.webhostbox.net","pid":715569,"level":40,"levelPath":"warn/service-runner","msg":"Startup finished","time":"2016-12-02T03:29:34.794Z","v":0}

I tried the command you gave me but now it got stuck on this message and there is no more output.

Arlolra (talkcontribs)

EADDRINUSE means that you didn't stop a previously listening instance.

"Startup finished" means the service is up and running. Did you try querying it?

MagaFun (talkcontribs)

I tried localhost:8000 but my browser just stuck at "Connecting".

By the way my site has HSTS enabled.

Arlolra (talkcontribs)

Hmm, I'm not sure how HSTS would play in here.

You confirmed it's listening on 8000, right?

If you're using some sort of shared hosting / cloud infrastructure, maybe localhost isn't what you think it is. Do you have an assigned IP? Maybe try setting that as the host in Parsoid's config instead.

MagaFun (talkcontribs)

I could confirm it is listening on 8000.

I do am using shared hosting, and I changed the "domain" in the "mwApis" section to my IP address. I still cannot query it. The output hostname is still "cp-hk-1.webhostbox.net", which is not my domain.

The reason I mentioned HSTS is because I think the issue below mine by 59.163.27.11 could also play a role here.

Arlolra (talkcontribs)

Maybe verify that you browser is actually sending requests there? Run,

nc -l localhost 8000

and then try to visit it in the browser. You should see the http request.

Something else to try is eliminating the web frontend altogether. Parsoid comes with a command line tool.

node --max-old-space-size=128 bin/parse.js --config --domain localhost Main_Page < /dev/null

MagaFun (talkcontribs)

I ran nc -l localhost 8000 but it says command not found, I couldn't install that command either.

Any alternative to that? Thanks.

Arlolra (talkcontribs)

netcat

MagaFun (talkcontribs)

Netcat doesn't work either, I don't think my host installed that.

Tgr (talkcontribs)

I've run into a similar issue: I installed parsoid via the Debian package on a virtual host, and it tries to start 24(!) workers with 756M each. --max-old-space-size does not seem to have any effect; -n works but it's not easy to use with the init.d script which does not insert -- at the right places in the start-stop-daemon commands, and then I get a bunch of EADDRINUSE errors on restarting because the old service was not shut down. In the end I just replaced the contents of do_stop{} with killall nodejs as a terrible hack and that seems to work.