Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 9725403

Browse files
authored
Merge pull request #1712 from janhq/chore/release-1.0.3
sync dev to main for release 1.0.3
2 parents 7938c34 + f5c3b02 commit 9725403

File tree

4 files changed

+77
-45
lines changed

4 files changed

+77
-45
lines changed

.github/workflows/cortex-cpp-quality-gate.yml

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -188,40 +188,40 @@ jobs:
188188
AWS_SECRET_ACCESS_KEY: "${{ secrets.MINIO_SECRET_ACCESS_KEY }}"
189189
AWS_DEFAULT_REGION: "${{ secrets.MINIO_REGION }}"
190190

191-
build-docker-and-test:
192-
runs-on: ubuntu-latest
193-
steps:
194-
- name: Getting the repo
195-
uses: actions/checkout@v3
196-
with:
197-
submodules: 'recursive'
198-
199-
- name: Set up QEMU
200-
uses: docker/setup-qemu-action@v3
201-
202-
- name: Set up Docker Buildx
203-
uses: docker/setup-buildx-action@v3
191+
# build-docker-and-test:
192+
# runs-on: ubuntu-latest
193+
# steps:
194+
# - name: Getting the repo
195+
# uses: actions/checkout@v3
196+
# with:
197+
# submodules: 'recursive'
198+
199+
# - name: Set up QEMU
200+
# uses: docker/setup-qemu-action@v3
201+
202+
# - name: Set up Docker Buildx
203+
# uses: docker/setup-buildx-action@v3
204204

205-
- name: Run Docker
206-
run: |
207-
docker build -t menloltd/cortex:test -f docker/Dockerfile .
208-
docker run -it -d -p 3928:39281 --name cortex menloltd/cortex:test
209-
210-
- name: use python
211-
uses: actions/setup-python@v5
212-
with:
213-
python-version: "3.10"
214-
215-
- name: Run e2e tests
216-
run: |
217-
cd engine
218-
python -m pip install --upgrade pip
219-
python -m pip install -r e2e-test/requirements.txt
220-
pytest e2e-test/test_api_docker.py
221-
222-
- name: Run Docker
223-
continue-on-error: true
224-
if: always()
225-
run: |
226-
docker stop cortex
227-
docker rm cortex
205+
# - name: Run Docker
206+
# run: |
207+
# docker build -t menloltd/cortex:test -f docker/Dockerfile .
208+
# docker run -it -d -p 3928:39281 --name cortex menloltd/cortex:test
209+
210+
# - name: use python
211+
# uses: actions/setup-python@v5
212+
# with:
213+
# python-version: "3.10"
214+
215+
# - name: Run e2e tests
216+
# run: |
217+
# cd engine
218+
# python -m pip install --upgrade pip
219+
# python -m pip install -r e2e-test/requirements.txt
220+
# pytest e2e-test/test_api_docker.py
221+
222+
# - name: Run Docker
223+
# continue-on-error: true
224+
# if: always()
225+
# run: |
226+
# docker stop cortex
227+
# docker rm cortex

engine/cli/main.cc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,23 @@ int main(int argc, char* argv[]) {
9797
if (result.has_error()) {
9898
CTL_ERR("Error creating config file: " << result.error());
9999
}
100+
namespace fmu = file_manager_utils;
101+
// Override data folder path if it is configured and changed
102+
if (!fmu::cortex_data_folder_path.empty()) {
103+
auto cfg = file_manager_utils::GetCortexConfig();
104+
if (cfg.dataFolderPath != fmu::cortex_data_folder_path ||
105+
cfg.logFolderPath != fmu::cortex_data_folder_path) {
106+
cfg.dataFolderPath = fmu::cortex_data_folder_path;
107+
cfg.logFolderPath = fmu::cortex_data_folder_path;
108+
auto config_path = file_manager_utils::GetConfigurationPath();
109+
auto result =
110+
config_yaml_utils::CortexConfigMgr::GetInstance().DumpYamlConfig(
111+
cfg, config_path.string());
112+
if (result.has_error()) {
113+
CTL_ERR("Error update " << config_path.string() << result.error());
114+
}
115+
}
116+
}
100117
}
101118

102119
RemoveBinaryTempFileIfExists();
@@ -164,7 +181,7 @@ int main(int argc, char* argv[]) {
164181
t1.detach();
165182
}
166183

167-
trantor::FileLogger async_file_logger;
184+
static trantor::FileLogger async_file_logger;
168185
SetupLogger(async_file_logger, verbose);
169186

170187
if (should_install_server) {

engine/main.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,23 @@ int main(int argc, char* argv[]) {
225225
if (result.has_error()) {
226226
LOG_ERROR << "Error creating config file: " << result.error();
227227
}
228+
namespace fmu = file_manager_utils;
229+
// Override data folder path if it is configured and changed
230+
if (!fmu::cortex_data_folder_path.empty()) {
231+
auto cfg = file_manager_utils::GetCortexConfig();
232+
if (cfg.dataFolderPath != fmu::cortex_data_folder_path ||
233+
cfg.logFolderPath != fmu::cortex_data_folder_path) {
234+
cfg.dataFolderPath = fmu::cortex_data_folder_path;
235+
cfg.logFolderPath = fmu::cortex_data_folder_path;
236+
auto config_path = file_manager_utils::GetConfigurationPath();
237+
auto result =
238+
config_yaml_utils::CortexConfigMgr::GetInstance().DumpYamlConfig(
239+
cfg, config_path.string());
240+
if (result.has_error()) {
241+
CTL_ERR("Error update " << config_path.string() << result.error());
242+
}
243+
}
244+
}
228245
}
229246

230247
// Delete temporary file if it exists

engine/utils/file_manager_utils.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ inline config_yaml_utils::CortexConfig GetDefaultConfig() {
156156
auto config_path = GetConfigurationPath();
157157
auto default_data_folder_name = GetDefaultDataFolderName();
158158
auto default_data_folder_path =
159-
file_manager_utils::GetHomeDirectoryPath() / default_data_folder_name;
159+
cortex_data_folder_path.empty()
160+
? file_manager_utils::GetHomeDirectoryPath() /
161+
default_data_folder_name
162+
: std::filesystem::path(cortex_data_folder_path);
160163

161164
return config_yaml_utils::CortexConfig{
162165
.logFolderPath = default_data_folder_path.string(),
@@ -192,20 +195,15 @@ inline cpp::result<void, std::string> CreateConfigFileIfNotExist() {
192195
return {};
193196
}
194197

195-
auto default_data_folder_name = GetDefaultDataFolderName();
196-
197198
CLI_LOG("Config file not found. Creating one at " + config_path.string());
198199
auto config = GetDefaultConfig();
199200
CLI_LOG("Default data folder path: " + config.dataFolderPath);
200-
return cyu::CortexConfigMgr::GetInstance().DumpYamlConfig(config,
201-
config_path.string());
201+
return cyu::CortexConfigMgr::GetInstance().DumpYamlConfig(
202+
config, config_path.string());
202203
}
203204

204205
inline config_yaml_utils::CortexConfig GetCortexConfig() {
205206
auto config_path = GetConfigurationPath();
206-
auto default_data_folder_name = GetDefaultDataFolderName();
207-
auto default_data_folder_path =
208-
file_manager_utils::GetHomeDirectoryPath() / default_data_folder_name;
209207

210208
auto default_cfg = GetDefaultConfig();
211209
return config_yaml_utils::CortexConfigMgr::GetInstance().FromYaml(

0 commit comments

Comments
 (0)