Orphaned Ruby processes: `nanoc view` needs quitting before closing terminal

14 views
Skip to first unread message

Dave Everitt

unread,
Jul 22, 2020, 5:46:11 PM7/22/20
to nanoc
Putting this here as a cautionary note for anyone using `nanoc view`.

The fan on my laptop was spinning up for no apparent reason - obviously high CPU load, so checked in terminal using `top`, and saw two orphaned ruby processes running at 90+% CPU, and jumping between them so I couldn't grab the PID number to kill them.

I used `ps -ax | grep "ruby"` and saw that they'd been initiated by `nanoc view`. They didn't respond to `kill <PID>` so I used Activity Monitor to force-quit them both (could also have used `kill -9 <PID>`).

Turns out quitting the terminal  without first using `ctrl-C` to kill the local server leaves the Ruby server for `nanoc view` running in the background and slowly (apparently eating up a huge slice of the CPU.

For me in this case it was quitting VSCode with a terminal console window still running `nanoc view`, but the same would apply to Apple's Terminal app.

Might be worth mentioning in the docs, as I imagine a lot of people will be wondering why their fan is spinning up days after quitting their Nanoc development session…

Pito Salas

unread,
Jul 22, 2020, 7:08:12 PM7/22/20
to na...@googlegroups.com
Yes this has been a constant phenomenon for me. But I assumed it was ruby not nanoc that was the guilty party. I wasn’t aware that control-c would make the process actually terminate. Good to know!

Pito Salas 
Computer Science
Brandeis Univeristy 


On Jul 22, 2020, at 5:46 PM, Dave Everitt <dever...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "nanoc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nanoc+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nanoc/db3ac01d-abe5-4b57-935b-a85b0dfd42acn%40googlegroups.com.

Jan Maurits Faber

unread,
Jul 23, 2020, 2:37:44 AM7/23/20
to nanoc
I've experienced this as well, it can also happen if it crashes and you restart it. I've added this line to my rake file to alert me:
 if !Gem.win_platform? && `ps`.lines.any?{|l| l.chomp =~ /(\d+).+guard\s/}
   
puts "Guard is already running. Can be stopped with: kill #{$1}"
end

To unsubscribe from this group and stop receiving emails from it, send an email to na...@googlegroups.com.

Dave Everitt

unread,
Jul 23, 2020, 7:01:11 AM7/23/20
to nanoc
Like the warning code idea! @Pito - it's not Nanoc itself, but (I presume) the Ruby server it fires up, which seems to leak memory over time when it's left 'orphaned'. Apparently it also happens if you launch IRB and close the Terminal window while it's still running. It's taken me years to work this one out - but an hour last night after the spinning fan and I finally got to the cause.

If you run `ps -ax | grep "ruby"` you can see the original process - for me, two entries "nanoc view" came up like this:

/usr/local/opt/ruby/bin/ruby /usr/local/bin/nanoc view

Reply all
Reply to author
Forward
0 new messages