Work on copy config if needed.
This commit is contained in:
@@ -24,6 +24,9 @@ exports.load_config = function () {
|
|||||||
console.log(`CWD: ${cwd}`);
|
console.log(`CWD: ${cwd}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (cwd == '/') {
|
||||||
|
cwd = '[home]';
|
||||||
|
}
|
||||||
console.log('Reading directory...');
|
console.log('Reading directory...');
|
||||||
let directory_list = fs_promises.readdir(cwd).then(function (read_dir_result) {
|
let directory_list = fs_promises.readdir(cwd).then(function (read_dir_result) {
|
||||||
console.log('Got contents:');
|
console.log('Got contents:');
|
||||||
@@ -81,18 +84,24 @@ exports.load_config = function () {
|
|||||||
|
|
||||||
// config = JSON.parse(fs.readFileSync(config_path));
|
// config = JSON.parse(fs.readFileSync(config_path));
|
||||||
// console.log('Config file read.');
|
// console.log('Config file read.');
|
||||||
} else if (fs.existsSync('config.json')) {
|
} else if (fs.existsSync(path.join(cwd, 'config.json'))) {
|
||||||
//fs.copyFileSync(default_config_path, config_path);
|
//fs.copyFileSync(default_config_path, config_path);
|
||||||
//console.log('Default config file copied: '+config_directory);
|
//console.log('Default config file copied: '+config_directory);
|
||||||
|
|
||||||
console.log(`Config file (config.json) not found under ${config_directory}. Using config in CWD. ${process.cwd()}`);
|
console.log(`Config file (config.json) not found under ${config_directory}. Using config in CWD. ${cwd}`);
|
||||||
config_path = 'config.json';
|
config_path = path.join(cwd, 'config.json');
|
||||||
|
|
||||||
// config = JSON.parse(fs.readFileSync('config.json'));
|
console.log(`Config file (config.json) not found under ${config_directory}. Using config in CWD. ${cwd}`);
|
||||||
// console.log('Config file read.');
|
found_config_path = path.join(cwd, 'config.json');
|
||||||
|
|
||||||
//console.log('Config file (config.json) not found under '+config_directory+'. Using config in CWD.');
|
fs.copyFileSync(found_config_path, config_path);
|
||||||
//config = JSON.parse(fs.readFileSync('config.json'));
|
console.log(`Found config file copied: ${config_directory}`);
|
||||||
|
} else if (fs.existsSync(path.join(cwd, 'config.json.default'))) {
|
||||||
|
console.log(`Config file (config.json) not found under ${config_directory} or CWD. Using default config in CWD. ${cwd}`);
|
||||||
|
default_config_path = path.join(cwd, 'config.json.default');
|
||||||
|
|
||||||
|
fs.copyFileSync(default_config_path, config_path);
|
||||||
|
console.log(`Default config file copied: ${config_directory}`);
|
||||||
} else {
|
} else {
|
||||||
console.log('Can not find a config file.');
|
console.log('Can not find a config file.');
|
||||||
|
|
||||||
@@ -105,6 +114,10 @@ exports.load_config = function () {
|
|||||||
config.home_directory = home_directory; // From the OS platform
|
config.home_directory = home_directory; // From the OS platform
|
||||||
config.tmp_directory = tmp_directory; // From the OS platform
|
config.tmp_directory = tmp_directory; // From the OS platform
|
||||||
|
|
||||||
|
config.app_root_path = config.app_root_path.replace('[home]', home_directory);
|
||||||
|
config.app_root_path = config.app_root_path.replace('[tmp]', tmp_directory);
|
||||||
|
console.log(config.app_root_path);
|
||||||
|
|
||||||
config.host_file_cache_path = config.host_file_cache_path.replace('[home]', home_directory);
|
config.host_file_cache_path = config.host_file_cache_path.replace('[home]', home_directory);
|
||||||
config.host_file_cache_path = config.host_file_cache_path.replace('[tmp]', tmp_directory);
|
config.host_file_cache_path = config.host_file_cache_path.replace('[tmp]', tmp_directory);
|
||||||
console.log(config.host_file_cache_path);
|
console.log(config.host_file_cache_path);
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
"event_location_id": "7ReVVemiSM0",
|
"event_location_id": "7ReVVemiSM0",
|
||||||
"event_session_id": null,
|
"event_session_id": null,
|
||||||
|
|
||||||
|
"app_root_path": "[home]/tmp/OSIT/native_app",
|
||||||
|
|
||||||
"api_secret_key": "dFP6J9DVj9hUgIMn-fNIqg",
|
"api_secret_key": "dFP6J9DVj9hUgIMn-fNIqg",
|
||||||
"api_remote_base_url": "https://dev-fastapi.oneskyit.com",
|
"api_remote_base_url": "https://dev-fastapi.oneskyit.com",
|
||||||
"api_local_base_url": "http://dev-fastapi.oneskyit.local:5005",
|
"api_local_base_url": "http://dev-fastapi.oneskyit.local:5005",
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
"event_location_code": "",
|
"event_location_code": "",
|
||||||
"event_session_id": "",
|
"event_session_id": "",
|
||||||
|
|
||||||
|
"app_root_path": "[home]/OSIT/native_app",
|
||||||
|
|
||||||
"api_secret_key": "ABCD1234XYZ",
|
"api_secret_key": "ABCD1234XYZ",
|
||||||
|
|
||||||
"api_server_base_url": "http://dev-api.oneskyit.local:5005",
|
"api_server_base_url": "http://dev-api.oneskyit.local:5005",
|
||||||
|
|||||||
Reference in New Issue
Block a user