<commit_before>require 'yaml'
require_relative 'mongo_cluster/security'
require_relative 'mongo_cluster/storage'
require_relative 'mongo_cluster/replica_set'
require_relative 'helpers/service'

module MongoCluster
  extend Service

  mattr_reader :service_name do
    'mongod'
  end

  mattr_reader :conf_path do
    Pathname('/etc/mongod.conf')
  end

  def self.init
    Storage.init
    Security.init
    set_conf
    start
    chkconfig_on
  end

  def self.read_conf
    YAML.load_file(conf_path)
  end

  private

  def self.set_conf
    File.write(conf_path, generate_conf)
  end

  def self.generate_conf
    <<-EOF
net:
  port: #{ReplicaSet.member.host.split(':').last}

systemLog:
  destination: file
  logAppend: true
  path: #{Storage.mounts.log.path.join('mongod.log')}

storage:
  dbPath: #{Storage.mounts.data.path}
  journal:
    enabled: true

security:
  keyFile: #{Security.settings.keyFile.fetch(:path)}
  transitionToAuth: #{!Security.allow_anonymous?}

processManagement:
  fork: true
  pidFilePath: #{Storage.run_path.join('mongod.pid')}

replication:<commit_msg>Remove NOT from transitionToAuth value<commit_after>require 'yaml'
require_relative 'mongo_cluster/security'
require_relative 'mongo_cluster/storage'
require_relative 'mongo_cluster/replica_set'
require_relative 'helpers/service'

module MongoCluster
  extend Service

  mattr_reader :service_name do
    'mongod'
  end

  mattr_reader :conf_path do
    Pathname('/etc/mongod.conf')
  end

  def self.init
    Storage.init
    Security.init
    set_conf
    start
    chkconfig_on
  end

  def self.read_conf
    YAML.load_file(conf_path)
  end

  private

  def self.set_conf
    File.write(conf_path, generate_conf)
  end

  def self.generate_conf
    <<-EOF
net:
  port: #{ReplicaSet.member.host.split(':').last}

systemLog:
  destination: file
  logAppend: true
  path: #{Storage.mounts.log.path.join('mongod.log')}

storage:
  dbPath: #{Storage.mounts.data.path}
  journal:
    enabled: true

security:
  keyFile: #{Security.settings.keyFile.fetch(:path)}
  transitionToAuth: #{Security.allow_anonymous?}

processManagement:
  fork: true
  pidFilePath: #{Storage.run_path.join('mongod.pid')}

replication:
{'fraction_non_alphanumeric': 0.1051912568306011, 'fraction_numerical': 0.0, 'mean_word_length': 4.193853427895981, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5680945', 'n_tokens_mistral': 772, 'n_tokens_neox': 759, 'n_words': 147}