{% set socket = parameter_dict['socket'] -%}
{% set extra_dict = parameter_dict['extra-dict'] -%}
{% set engine = parameter_dict['engine'] -%}
{% set plugins = [] -%}

{% if not engine or engine == 'InnoDB' -%}
{% do extra_dict.setdefault('innodb_file_per_table',  '1') -%}
{% endif -%}

{% if not engine or engine == 'RocksDB' -%}
{% do plugins.append('ha_rocksdb') -%}
{% do extra_dict.setdefault('rocksdb_keep_log_file_num', '64') -%}
{% do extra_dict.setdefault('rocksdb_max_log_file_size', '16M') -%}
{% endif -%}

[mysqld]
skip_networking
socket = {{ socket }}
datadir = {{ parameter_dict['data-directory'] }}
tmpdir = {{ parameter_dict['tmp-directory'] }}
pid_file = {{ parameter_dict['pid-file'] }}
log_error = {{ parameter_dict['error-log'] }}
slow_query_log
slow_query_log_file = {{ parameter_dict['slow-query-log'] }}

init_file = {{ parameter_dict['init-file'] }}
log_warnings = 1
disable-log-bin
{%- if plugins %}
plugin-load = {{ ';'.join(plugins) }}
{%- endif %}

## The following settings come from ERP5 configuration.

max_allowed_packet = 128M
query_cache_size = 32M
innodb_locks_unsafe_for_binlog = 1

# Some dangerous settings you may want to uncomment temporarily
# if you only want performance or less disk access.
{% set x = '' if extra_dict.pop('relaxed-writes', False) else '#' -%}
{{x}}innodb_flush_log_at_trx_commit = 0
{{x}}innodb_flush_method = nosync
{{x}}innodb_doublewrite = 0
{{x}}sync_frm = 0

# Extra parameters.
{%- for k, v in extra_dict.iteritems() %}
{%- do assert('-' not in k) %}
{{ k }} = {{ v }}
{%- endfor %}

# Force utf8 usage
collation_server = utf8_unicode_ci
character_set_server = utf8
skip_character_set_client_handshake

[client]
socket = {{ socket }}
user = root
