Skip to content

Commit

Permalink
fix issue spesmilo#103 check open files limit during initialization
Browse files Browse the repository at this point in the history
Prevent database corruption due to default open file limits.
If limit is too low, print an error message and exit.
  • Loading branch information
shsmith committed Jul 18, 2015
1 parent e434388 commit b591c0f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions run_electrum_server
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import threading
import json
import os
import imp
import resource


if os.path.dirname(os.path.realpath(__file__)) == os.getcwd():
Expand All @@ -49,6 +50,12 @@ if os.getuid() == 0:
print "Run the install script to create a non-privileged user."
sys.exit()

# prevent database corruption due to default open file limits
softlimit, hardlimit = resource.getrlimit(resource.RLIMIT_OFILE)
if hardlimit < 64000:
print "Warning: Your open files limit is too low."
sys.exit()

def attempt_read_config(config, filename):
try:
with open(filename, 'r') as f:
Expand Down

0 comments on commit b591c0f

Please sign in to comment.