The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 18, 2019, 08:12:12 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Apache, OS-X and ULIMIT... a little chunk of weirdness  (Read 11051 times)
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« on: April 29, 2008, 10:44:35 PM »

So I do some work on Apache on my Powerbook... change around some settings, add SSL for some tests I am doing and suddenly I'm getting this error:

line 70: ulimit: open files: cannot modify limit: Invalid argument

Apache starts normally, and everything seems to run, but it's weird and I don't like it. Digging around a bit, I found an obscure post pointing me in this direction: apachectl (which is what I use to start Apache) is a shell script. On line 70, it is attempting to reset the ULIMIT_MAX_FILES when Apache starts.

Looking at the shell script, we see this:
60  # Set this variable to a command that increases the maximum
61  # number of file descriptors allowed per child process. This is
62  # critical for configurations that use many file descriptors,
63  # such as mass vhosting, or a multithreaded server.
64  ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`"
65  # --------------------                              --------------------
66  # ||||||||||||||||||||   END CONFIGURATION SECTION  ||||||||||||||||||||
67
68  # Set the maximum number of file descriptors allowed per child process.
69  if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then
70      $ULIMIT_MAX_FILES
71  fi


Line 64 is creating the command to set the ULIMIT for us. It essentially says to run the command ulimit -H -n and the answer of that goes into the string ulimit -S -n - trying to set the soft limit for Apache to the hard limit of the system. The problem, is that OS-X, like AIX and some Solarises, return the value "unlimited" for the number of file descriptors, which cannot be used in the command ulimit -S -n, so we get the syntax error "cannot modify limit: Invalid argument" when we try to start Apache. Since the command fails to do anything, and since the file descriptors for Apache is unlimited, this is a no-damage error and Apache starts normally anyway.

But if it bothers you (like it did me) then all you need to do is comment out lines 69, 70 and 71 because they are meaningless to OS-X and it'll start up without complaint.

After a day of niggily little bastards like this one, figured I'd post about it and hope I eased up someone else's day Wink
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
emonk
Rookie
**
Offline Offline

Posts: 44


View Profile
« Reply #1 on: May 01, 2008, 05:57:03 AM »

 That whole ulimit thing is one of the biggest reasons I hate Linux (not that I don't hate most every other OS more). It pisses me off to no end when my webserver is handling a slashdotting, or a Digg front page well but then the sumabitch runs out of file descriptors, because some asshat at redhat decided no one would ever need more than a thousand files open at a time, and I hadn't bothered to recompile the kernel before going live with the site.
Logged
arms
Expert
****
Offline Offline

Posts: 235



View Profile
« Reply #2 on: May 01, 2008, 07:05:49 PM »

i don't know about redhat but in ubuntu (and debian i suppose) you can set file descriptor limits in /etc/security/limits.conf.
whether or not that is superseded by limits in the kernel i have no idea.
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #3 on: May 01, 2008, 10:06:37 PM »

As I mentioned, the problem here is no a limit, but the fact that OS-X, like AIX and some others returns the word "unlimited" when you ask for the ULIMIT number, and the Apache script tries to then put the word "unlimited" in as the value to set the ulimit. It's a bug in the way Apache handles the ulimit function in apachectl, not an OS problem... although I can see where it would've been moreso in the past...
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!