<commit_before>package io.spacedog.server;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;

import com.amazonaws.regions.Regions;

import io.spacedog.http.SpaceBackend;
import io.spacedog.http.SpaceEnv;
import io.spacedog.utils.Exceptions;
import io.spacedog.utils.Optional7;
import io.spacedog.utils.Utils;

public class ServerConfiguration {

	private static final String HOME_PATH = "spacedog.home.path";
	private static final String PRODUCTION = "spacedog.production";
	private static final String OFFLINE = "spacedog.offline";
	private static final String BACKEND_CREATE_RESTRICTED = "spacedog.backend.create.restricted";
	private static final String SERVER_PORT = "spacedog.server.port";
	private static final String SERVER_GREEN_CHECK = "spacedog.server.green.check";
	private static final String SERVER_GREEN_TIMEOUT = "spacedog.server.green.timeout";
	private static final String SERVER_USER_AGENT = "spacedog.server.user.agent";
	private static final String ELASTIC_DATA_PATH = "spacedog.elastic.data.path";
	private static final String ELASTIC_HTTP_ENABLED = "spacedog.elastic.http.enabled";
	private static final String ELASTIC_NETWORK_HOST = "spacedog.elastic.network.host";
	private static final String ELASTIC_SNAPSHOTS_PATH = "spacedog.elastic.snapshots.path";
	private static final String MAIL_SMTP_DEBUG = "spacedog.mail.smtp.debug";
	private static final String MAIL_DOMAIN = "spacedog.mail.domain";
	private static final String MAIL_MAILGUN_KEY = "spacedog.mail.mailgun.key";
	private static final String AWS_SUPERDOG_NOTIFICATION_TOPIC = "spacedog.aws.superdog.notification.topic";
	private static final String AWS_BUCKET_PREFIX = "spacedog.aws.bucket.prefix";
	private static final String AWS_REGION = "spacedog.aws.region";

	private SpaceEnv env;

	public ServerConfiguration() {
		this(SpaceEnv.env());
	}

	public ServerConfiguration(SpaceEnv env) {
		this.env = env;
		this.log();

		if (isProduction()) {
			// Force Fluent HTTP to production mode
			System.setProperty("PROD_MODE", "true");
		}

	}

	public Path homePath() {
		Optional7<String> path = env.get(HOME_PATH);
		return path.isPresent() ? Paths.get(path.get()) //
				: Paths.get(System.getProperty("user.home"), "spacedog");
	}

	public boolean isProduction() {
		return env.get(PRODUCTION, false);
	}

	public boolean isOffline() {
		return env.get(OFFLINE, false);
	}

	public SpaceBackend apiBackend() {
		return env.apiBackend();
	}

	public SpaceBackend wwwBackend() {
		return env.wwwBackend();
	}

	public int serverPort() {
		return env.get(SERVER_PORT, 8443);
	}

	public boolean serverGreenCheck() {
		return env.get(SERVER_GREEN_CHECK, true);
	}

	public int serverGreenTimeout() {
		return env.get(SERVER_GREEN_TIMEOUT, 60);
	}

	public Path elasticDataPath() {
		Optional7<String> path = env.get(ELASTIC_DATA_PATH);
		return path.isPresent() ? //
				Paths.get(path.get()) : homePath().resolve("data");
	}<commit_msg>Add config path to server configuration<commit_after>package io.spacedog.server;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;

import com.amazonaws.regions.Regions;

import io.spacedog.client.http.SpaceBackend;
import io.spacedog.client.http.SpaceEnv;
import io.spacedog.utils.Exceptions;
import io.spacedog.utils.Optional7;
import io.spacedog.utils.Utils;

public class ServerConfiguration {

	private static final String HOME_PATH = "spacedog.home.path";
	private static final String PRODUCTION = "spacedog.production";
	private static final String OFFLINE = "spacedog.offline";
	private static final String BACKEND_CREATE_RESTRICTED = "spacedog.backend.create.restricted";
	private static final String SERVER_PORT = "spacedog.server.port";
	private static final String SERVER_GREEN_CHECK = "spacedog.server.green.check";
	private static final String SERVER_GREEN_TIMEOUT = "spacedog.server.green.timeout";
	private static final String SERVER_USER_AGENT = "spacedog.server.user.agent";
	private static final String ELASTIC_CONFIG_PATH = "spacedog.elastic.config.path";
	private static final String ELASTIC_DATA_PATH = "spacedog.elastic.data.path";
	private static final String ELASTIC_HTTP_ENABLED = "spacedog.elastic.http.enabled";
	private static final String ELASTIC_NETWORK_HOST = "spacedog.elastic.network.host";
	private static final String ELASTIC_SNAPSHOTS_PATH = "spacedog.elastic.snapshots.path";
	private static final String MAIL_SMTP_DEBUG = "spacedog.mail.smtp.debug";
	private static final String MAIL_DOMAIN = "spacedog.mail.domain";
	private static final String MAIL_MAILGUN_KEY = "spacedog.mail.mailgun.key";
	private static final String AWS_SUPERDOG_NOTIFICATION_TOPIC = "spacedog.aws.superdog.notification.topic";
	private static final String AWS_BUCKET_PREFIX = "spacedog.aws.bucket.prefix";
	private static final String AWS_REGION = "spacedog.aws.region";

	private SpaceEnv env;

	public ServerConfiguration() {
		this(SpaceEnv.env());
	}

	public ServerConfiguration(SpaceEnv env) {
		this.env = env;
		this.log();

		if (isProduction()) {
			// Force Fluent HTTP to production mode
			System.setProperty("PROD_MODE", "true");
		}

	}

	public Path homePath() {
		Optional7<String> path = env.get(HOME_PATH);
		return path.isPresent() ? Paths.get(path.get()) //
				: Paths.get(System.getProperty("user.home"), "spacedog");
	}

	public boolean isProduction() {
		return env.get(PRODUCTION, false);
	}

	public boolean isOffline() {
		return env.get(OFFLINE, false);
	}

	public SpaceBackend apiBackend() {
		return env.apiBackend();
	}

	public SpaceBackend wwwBackend() {
		return env.wwwBackend();
	}

	public int serverPort() {
		return env.get(SERVER_PORT, 8443);
	}

	public boolean serverGreenCheck() {
		return env.get(SERVER_GREEN_CHECK, true);
	}

	public int serverGreenTimeout() {
		return env.get(SERVER_GREEN_TIMEOUT, 60);
	}

	public Path elasticConfigPath() {
		Optional7<String> path = env.get(ELASTIC_CONFIG_PATH);
		return path.isPresent() ? //
				Paths.get(path.get()) : homePath().resolve("config");
	}

	public Path elasticDataPath() {
		Optional7<String> path = env.get(ELASTIC_DATA_PATH);
		return path.isPresent() ? //
				Paths.get(path.get()) : homePath().resolve("data");
	}
{'fraction_non_alphanumeric': 0.11244541484716157, 'fraction_numerical': 0.002963194011228946, 'mean_word_length': 5.220174587778856, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '2142605', 'n_tokens_mistral': 2182, 'n_tokens_neox': 2082, 'n_words': 461}