[Solved] lighty crashes if folder contains >2500 files
Added by capedcrusader029 over 6 years ago
Hi community,
I installed lighty with openwrt on 4mb (flash), 32mb ram system and enabled directory listing. Browsing through folders is generally fine with directory listing.
If any folder contains > 2500 items, the lighty becomes unresponsive. I have to reboot the server (not just lighttpd).
Any help , TIA.
p.s: I installed lighty on my mb air and it doesn't have any problem. When the same folder with 2500+ items is clicked, directory listing is shown with the contents.
Replies (5)
RE: lighty crashes if folder contains >2500 itmes - Added by gstrauss over 6 years ago
Sounds like 32 MB memory is not enough for lighttpd to read such a large directory into memory, sort it, and produce an HTML page. You can replace mod_dirlisting with your own script to produce a directory listing in a more memory-scarce fashion (or you could not have such large directories). Another alternative is to disable mod_dirlisting for this location and instead to use mod_indexfile. Depending on how frequently this directory was updated, a periodic script could be run to generate a static index.html out-of-band from lighttpd and whatever generates the directory listing index.html could be written to run on your memory-scarce system.
To prevent lighttpd from causing the machine to become unresponsive, you probably should set a ulimit so that lighttpd does not cause memory to be exhausted on such huge directories and for the system to thrash to swap (if configured).
RE: lighty crashes if folder contains >2500 itmes - Added by capedcrusader029 over 6 years ago
thanks a lot for your reply.
Yes, exactly I wanted to create my own mod_directory listing script to just render an HTML page with plain item names (no html tags) instead of default script.
I went through documentation but couldn't find anything. Can you please point me in right direction?
RE: lighty crashes if folder contains >2500 itmes - Added by gstrauss over 6 years ago
How about a CGI script;
#!/bin/sh echo "Content-Type: text/plain" echo ls -f
(leave off the -f if you want the directory listing sorted by ls)
RE: lighty crashes if folder contains >2500 itmes - Added by capedcrusader029 over 6 years ago
even before scripting this, I just tried to ls > /path/to/folder/ , same problem with device.
I guess that's a limit on this small-server system I guess.
Thank you though!
RE: lighty crashes if folder contains >2500 itmes - Added by gstrauss over 6 years ago
Use 'ls -f' for an unsorted listing, or write some script which does the same. For small-memory systems, you can write an HTML page that includes some javascrict which sorts the directory listing on the client side.