forked from shaba/openuds
Fixed sample settings & database recovery on backend
This commit is contained in:
parent
06c7a46d2a
commit
f1e27f1364
@ -32,7 +32,7 @@ DATABASES = {
|
|||||||
'PASSWORD': 'PASSWOR', # Not used with sqlite3.
|
'PASSWORD': 'PASSWOR', # Not used with sqlite3.
|
||||||
'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3.
|
'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3.
|
||||||
'PORT': '3306', # Set to empty string for default. Not used with sqlite3.
|
'PORT': '3306', # Set to empty string for default. Not used with sqlite3.
|
||||||
'CONN_MAX_AGE': 600, # Enable DB Pooling, 10 minutes max connection duration
|
# 'CONN_MAX_AGE': 600, # Enable DB Pooling, 10 minutes max connection duration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ALLOWED_HOSTS = '*'
|
ALLOWED_HOSTS = '*'
|
||||||
@ -121,6 +121,9 @@ CACHES = {
|
|||||||
'MAX_ENTRIES': 5000,
|
'MAX_ENTRIES': 5000,
|
||||||
'CULL_FREQUENCY': 3, # 0 = Entire cache will be erased once MAX_ENTRIES is reached, this is faster on DB. if other value, will remove 1/this number items fromm cache
|
'CULL_FREQUENCY': 3, # 0 = Entire cache will be erased once MAX_ENTRIES is reached, this is faster on DB. if other value, will remove 1/this number items fromm cache
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
'memory': {
|
||||||
|
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,11 @@ class JobThread(threading.Thread):
|
|||||||
done = True
|
done = True
|
||||||
except Exception:
|
except Exception:
|
||||||
# Databases locked, maybe because we are on a multitask environment, let's try again in a while
|
# Databases locked, maybe because we are on a multitask environment, let's try again in a while
|
||||||
logger.info('Database access locked... Retrying')
|
try:
|
||||||
|
connection.close()
|
||||||
|
except Exception as e:
|
||||||
|
logger.error('On job executor, closing db connection: {}'.format(e))
|
||||||
|
logger.info('Database access failed... Retrying')
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
# Ensures DB connection is released after job is done
|
# Ensures DB connection is released after job is done
|
||||||
@ -160,7 +164,8 @@ class Scheduler(object):
|
|||||||
# This in fact means that we have to retry operation, and retry will happen on main loop
|
# This in fact means that we have to retry operation, and retry will happen on main loop
|
||||||
# Look at this http://dev.mysql.com/doc/refman/5.0/en/innodb-deadlocks.html
|
# Look at this http://dev.mysql.com/doc/refman/5.0/en/innodb-deadlocks.html
|
||||||
# I have got some deadlock errors, but looking at that url, i found that it is not so abnormal
|
# I have got some deadlock errors, but looking at that url, i found that it is not so abnormal
|
||||||
logger.debug('Deadlock, no problem at all :-) (sounds hards, but really, no problem, will retry later :-) )')
|
# logger.debug('Deadlock, no problem at all :-) (sounds hards, but really, no problem, will retry later :-) )')
|
||||||
|
raise DatabaseError('Database access problems. Retrying connection')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def releaseOwnShedules():
|
def releaseOwnShedules():
|
||||||
@ -186,7 +191,7 @@ class Scheduler(object):
|
|||||||
time.sleep(self.granularity)
|
time.sleep(self.granularity)
|
||||||
self.executeOneJob()
|
self.executeOneJob()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception('Unexpected exception at run loop {0}: {1}'.format(e.__class__, e))
|
logger.error('Unexpected exception at run loop {0}: {1}'.format(e.__class__, e))
|
||||||
try:
|
try:
|
||||||
connection.close()
|
connection.close()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -51,7 +51,7 @@ import requests
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
__updated__ = '2015-05-27'
|
__updated__ = '2015-10-15'
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -480,12 +480,12 @@ class UserServiceManager(object):
|
|||||||
data=json.dumps({'user': userName, 'protocol': protocol}),
|
data=json.dumps({'user': userName, 'protocol': protocol}),
|
||||||
headers={'content-type': 'application/json'},
|
headers={'content-type': 'application/json'},
|
||||||
verify=False,
|
verify=False,
|
||||||
timeout=5)
|
timeout=2)
|
||||||
r = json.loads(r.content)
|
r = json.loads(r.content)
|
||||||
logger.debug('Sent pre connection to client using {}: {}'.format(url, r))
|
logger.debug('Sent pre connection to client using {}: {}'.format(url, r))
|
||||||
# In fact we ignore result right now
|
# In fact we ignore result right now
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error('Exception caught notifiying preConnection: {}. Check connection on destination machine: {}'.format(e, url))
|
logger.info('preConnection failed: {}. Check connection on destination machine: {}'.format(e, url))
|
||||||
|
|
||||||
def sendScript(self, uService, script):
|
def sendScript(self, uService, script):
|
||||||
'''
|
'''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user