GC settings for unicorn?

David Palm dvdplm at gmail.com
Thu Nov 26 09:39:32 EST 2009

Hi all,
we have a batch of unicorn workers running behind nginx in production since a week now. Works awesomely.

We're using REE 1.8.7 and I'd like to tune the GC settings to something like:

Now, how should I go about getting unicorn to pick that up the ENV? I tried sticking the above exports into /etc/profile.d/ree_gc_tuning.sh but when unicorn spawns workers they don't get the environment from the spawning user (root).

Our unicorn.rb config file has this in the after_fork section:

  # Unicorn master is started as root, which is fine, but let's
  # drop the workers to mongrel:mongrel
    uid, gid = Process.euid, Process.egid
    user, group = 'mongrel', 'mongrel'
    target_uid = Etc.getpwnam(user).uid
    target_gid = Etc.getgrnam(group).gid
    worker.tmp.chown(target_uid, target_gid)
    if uid != target_uid || gid != target_gid
      Process.initgroups(user, target_gid)
  rescue => e
    raise e

To verify the contents of the env at this stage of the init I inserted a:
	File.open('/tmp/unicorn_init.log','w'){|f| f << "Who am I? #{`whoami`}\n#{`env`}"}

The user is really "mongrel" at this stage and the env does not contain any of the GC tunings.

Is there a best practise regarding this? Where should env var setting go? Is tuning the GC something we'd want to be able to do in the unicorn config file directly (feature request...)?

Thanks for any pointers!


More information about the mongrel-unicorn mailing list