Skip to content

Commit

Permalink
fix #25
Browse files Browse the repository at this point in the history
  • Loading branch information
tmori committed Feb 11, 2024
1 parent e48d579 commit ca9a45b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/hako/utils/hako_config_loader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "nlohmann/json.hpp"
#include "types/hako_types.hpp"
#include <cstdlib> // for std::getenv
#include <fstream>
#include <iostream>

Expand All @@ -12,7 +13,10 @@ typedef struct {

static inline void hako_config_load(HakoConfigType &config)
{
std::ifstream ifs(HAKO_CONFIG_DEFAULT_PATH);
const char* env_path = std::getenv("HAKO_CONFIG_PATH");
std::string config_path = (env_path != nullptr) ? env_path : HAKO_CONFIG_DEFAULT_PATH;

std::ifstream ifs(config_path);
if (!ifs) {
config.param = nullptr;
}
Expand All @@ -21,4 +25,5 @@ static inline void hako_config_load(HakoConfigType &config)
}
}


#endif /* _HAKO_CONFIG_LOADER_HPP_ */
2 changes: 1 addition & 1 deletion src/include/config/hako_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

#define HAKO_PDU_CHANNEL_MAX 256

#define HAKO_CONFIG_DEFAULT_PATH "./hakoniwa_core_config.json"
#define HAKO_CONFIG_DEFAULT_PATH "/etc/hakoniwa/cpp_core_config.json"
#define HAKO_CONFIG_MAX_SEM 1024
#endif /* _HAKO_CONFIG_HPP_ */

0 comments on commit ca9a45b

Please sign in to comment.