<commit_before>"use strict";
// smtp network server
/* jshint node: true */

var net         = require('./tls_socket');
var logger      = require('./logger');
var config      = require('./config');
var conn        = require('./connection');
var out         = require('./outbound');
var plugins     = require('./plugins');
var constants   = require('./constants');
var os          = require('os');
var cluster     = require('cluster');
var async       = require('async');
var daemon      = require('daemon');

// Need these here so we can run hooks
logger.add_log_methods(exports, 'server');

var Server = exports;

var defaults = {
    inactivity_timeout: 600,
    daemon_log_file: '/var/log/haraka.log',
    daemon_pid_file: '/var/run/haraka.pid'
};

Server.load_smtp_ini = function () {
    Server.cfg = config.get('smtp.ini', {
        booleans: [
            '-main.daemonize',
            ],
    },
    Server.load_smtp_ini);

    for (var key in defaults) {
        if (Server.cfg[key] !== undefined) continue;
        Server.cfg[key] = defaults[key];
    }
};
Server.load_smtp_ini();

Server.daemonize = function (config_data) {
    var c = this.cfg.main;
    if (!c.daemonize) return;

    if (!process.env.__daemon) {
        // Remove process.on('exit') listeners otherwise
        // we get a spurious 'Exiting' log entry.
        process.removeAllListeners('exit');
        logger.lognotice('Daemonizing...');
    }

    var log_fd = require('fs').openSync(c.daemon_log_file, 'a');
    daemon({stdout: log_fd});

    // We are the daemon from here on...
    var npid = require('npid');
    try {<commit_msg>server: moved defaults obj into load_smtp_ini()<commit_after>"use strict";
// smtp network server
/* jshint node: true */

var net         = require('./tls_socket');
var logger      = require('./logger');
var config      = require('./config');
var conn        = require('./connection');
var out         = require('./outbound');
var plugins     = require('./plugins');
var constants   = require('./constants');
var os          = require('os');
var cluster     = require('cluster');
var async       = require('async');
var daemon      = require('daemon');

// Need these here so we can run hooks
logger.add_log_methods(exports, 'server');

var Server = exports;

Server.load_smtp_ini = function () {
    Server.cfg = config.get('smtp.ini', {
        booleans: [
            '-main.daemonize',
            ],
    },
    Server.load_smtp_ini);

    var defaults = {
        inactivity_timeout: 600,
        daemon_log_file: '/var/log/haraka.log',
        daemon_pid_file: '/var/run/haraka.pid'
    };

    for (var key in defaults) {
        if (Server.cfg[key] !== undefined) continue;
        Server.cfg[key] = defaults[key];
    }
};
Server.load_smtp_ini();

Server.daemonize = function (config_data) {
    var c = this.cfg.main;
    if (!c.daemonize) return;

    if (!process.env.__daemon) {
        // Remove process.on('exit') listeners otherwise
        // we get a spurious 'Exiting' log entry.
        process.removeAllListeners('exit');
        logger.lognotice('Daemonizing...');
    }

    var log_fd = require('fs').openSync(c.daemon_log_file, 'a');
    daemon({stdout: log_fd});

    // We are the daemon from here on...
    var npid = require('npid');
    try {
{'fraction_non_alphanumeric': 0.15765492102065615, 'fraction_numerical': 0.0018226002430133657, 'mean_word_length': 2.571583514099783, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5947420', 'n_tokens_mistral': 1038, 'n_tokens_neox': 1015, 'n_words': 249}