diff --git a/bench/config.py b/bench/config.py index c2d3abb3..e9f12d8a 100644 --- a/bench/config.py +++ b/bench/config.py @@ -88,36 +88,40 @@ def generate_nginx_config(bench='.'): }) write_config_file(bench, 'nginx.conf', config) -def generate_redis_celery_broker_config(bench='.'): +def generate_redis_celery_broker_config(bench='.', pid_db_save_path): """Redis that is used for queueing celery tasks""" _generate_redis_config( template_name='redis_celery_broker.conf', context={ "port": get_config().get('redis_async_broker_port', '12311'), - "bench_path": os.path.abspath(bench) + "bench_path": os.path.abspath(bench), + "pid_db_save_path": pid_db_save_path }, bench=bench ) -def generate_redis_async_broker_config(bench='.'): +def generate_redis_async_broker_config(bench='.', pid_db_save_path): """Redis that is used to do pub/sub""" _generate_redis_config( template_name='redis_async_broker.conf', context={ "port": get_config().get('redis_async_broker_port', '12311'), - "bench_path": os.path.abspath(bench) + "bench_path": os.path.abspath(bench), + "pid_db_save_path": pid_db_save_path }, bench=bench ) -def generate_redis_cache_config(bench='.'): +def generate_redis_cache_config(bench='.', pid_db_save_path): """Redis that is used and optimized for caching""" _generate_redis_config( template_name='redis_cache.conf', context={ "maxmemory": get_config().get('cache_maxmemory', '50'), "port": get_config().get('redis_cache_port', '11311'), - "redis_version": get_redis_version() + "redis_version": get_redis_version(), + "bench_path": os.path.abspath(bench), + "pid_db_save_path": pid_db_save_path }, bench=bench ) diff --git a/bench/templates/redis_async_broker.conf b/bench/templates/redis_async_broker.conf index 6766f424..5fa3f896 100644 --- a/bench/templates/redis_async_broker.conf +++ b/bench/templates/redis_async_broker.conf @@ -1,4 +1,5 @@ dbfilename redis_async_broker.rdb -pidfile redis_async_broker.pid +dir {{pid_db_save_path}} +pidfile {{pid_db_save_path}}/redis_async_broker.pid port {{port}} bench_path {{bench_path}} diff --git a/bench/templates/redis_cache.conf b/bench/templates/redis_cache.conf index dfb35872..57817e57 100644 --- a/bench/templates/redis_cache.conf +++ b/bench/templates/redis_cache.conf @@ -1,7 +1,9 @@ dbfilename redis_cache_dump.rdb -pidfile redis_cache.pid +dir {{pid_db_save_path}} +pidfile {{pid_db_save_path}}/redis_cache.pid port {{port}} maxmemory {{maxmemory}}mb maxmemory-policy allkeys-lru save "" -appendonly no \ No newline at end of file +appendonly no +bench_path {{bench_path}} diff --git a/bench/templates/redis_celery_broker.conf b/bench/templates/redis_celery_broker.conf index 6766f424..5fa3f896 100644 --- a/bench/templates/redis_celery_broker.conf +++ b/bench/templates/redis_celery_broker.conf @@ -1,4 +1,5 @@ dbfilename redis_async_broker.rdb -pidfile redis_async_broker.pid +dir {{pid_db_save_path}} +pidfile {{pid_db_save_path}}/redis_async_broker.pid port {{port}} bench_path {{bench_path}} diff --git a/bench/utils.py b/bench/utils.py index c5cdf4de..b888ca72 100644 --- a/bench/utils.py +++ b/bench/utils.py @@ -59,6 +59,10 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False, for dirname in ('apps', 'sites', 'config', 'logs'): os.mkdir(os.path.join(path, dirname)) + # This is folder to save the pid and redis db files for each redis process + pid_db_save_path = os.path.join(path, 'config', 'files') + os.mkdir(pid_db_save_path) + setup_logging() setup_env(bench=path) @@ -78,9 +82,9 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False, setup_socketio(bench=path) build_assets(bench=path) - generate_redis_celery_broker_config(bench=path) - generate_redis_cache_config(bench=path) - generate_redis_async_broker_config(bench=path) + generate_redis_celery_broker_config(bench=path, pid_db_save_path) + generate_redis_cache_config(bench=path, pid_db_save_path) + generate_redis_async_broker_config(bench=path, pid_db_save_path) if not no_procfile: setup_procfile(bench=path)