Skip to content

Commit 7892efc

Browse files
authored
Merge pull request #184 from KomodoPlatform/update_reproc
feat(reproc): update to last reproc
2 parents 675a902 + 7b7689d commit 7892efc

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

src/atomic.dex.app.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,8 +810,11 @@ namespace atomic_dex
810810
bool
811811
application::disconnect()
812812
{
813+
LOG_SCOPE_FUNCTION(INFO);
814+
813815
system_manager_.mark_system<mm2>();
814816
system_manager_.mark_system<coinpaprika_provider>();
817+
815818
get_dispatcher().sink<change_ticker_event>().disconnect<&application::on_change_ticker_event>(*this);
816819
get_dispatcher().sink<enabled_coins_event>().disconnect<&application::on_enabled_coins_event>(*this);
817820
get_dispatcher().sink<tx_fetch_finished>().disconnect<&application::on_tx_fetch_finished_event>(*this);

src/atomic.dex.mm2.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
//! Project Headers
1818
#include "atomic.dex.mm2.hpp"
19+
#include "atomic.dex.kill.hpp"
1920
#include "atomic.dex.mm2.config.hpp"
2021
#include "atomic.threadpool.hpp"
2122

@@ -111,18 +112,23 @@ namespace atomic_dex
111112

112113
mm2::~mm2() noexcept
113114
{
115+
m_mm2_running = false;
116+
117+
#if defined(_WIN32) || defined(WIN32)
118+
atomic_dex::kill_executable("mm2");
119+
#else
114120
const reproc::stop_actions stop_actions = {
115121
{reproc::stop::terminate, reproc::milliseconds(2000)},
116122
{reproc::stop::kill, reproc::milliseconds(5000)},
117123
{reproc::stop::wait, reproc::milliseconds(2000)}};
118124

119-
m_mm2_running = false;
120-
const auto ec = m_mm2_instance.stop(stop_actions);
125+
const auto ec = m_mm2_instance.stop(stop_actions).second;
121126

122127
if (ec)
123128
{
124129
VLOG_SCOPE_F(loguru::Verbosity_ERROR, "error: %s", ec.message().c_str());
125130
}
131+
#endif
126132

127133
if (m_mm2_init_thread.joinable())
128134
{
@@ -466,9 +472,15 @@ namespace atomic_dex
466472
nlohmann::to_json(json_cfg, cfg);
467473
// DVLOG_F(loguru::Verbosity_INFO, "command line {}", json_cfg.dump());
468474

469-
const std::array<std::string, 2> args = {(tools_path / "mm2").string(), json_cfg.dump()};
470-
reproc::redirect redirect_type = reproc::redirect::inherit;
471-
const auto ec = m_mm2_instance.start(args, {nullptr, tools_path.string().c_str(), {redirect_type, redirect_type, redirect_type}});
475+
const std::array<std::string, 2> args = {(tools_path / "mm2").string(), json_cfg.dump()};
476+
// auto redirect_type = reproc::redirect::parent;
477+
reproc::options options;
478+
options.redirect.parent = true;
479+
options.working_directory = strdup(tools_path.string().c_str());
480+
481+
std::cout << "tools path: " << tools_path.string() << std::endl;
482+
std::cout << "wd: " << options.working_directory << std::endl;
483+
const auto ec = m_mm2_instance.start(args, options);
472484

473485
if (ec)
474486
{
@@ -479,9 +491,11 @@ namespace atomic_dex
479491
using namespace std::chrono_literals;
480492
loguru::set_thread_name("mm2 init thread");
481493

482-
const auto wait_ec = m_mm2_instance.wait(2s);
494+
const auto wait_ec = m_mm2_instance.wait(2s).second;
483495

484-
if (wait_ec == reproc::error::wait_timeout)
496+
std::cout << wait_ec.value() << std::endl;
497+
std::cout << static_cast<int>(std::errc::timed_out) << std::endl;
498+
if (wait_ec.value() == static_cast<int>(std::errc::timed_out) || wait_ec.value() == 258)
485499
{
486500
DVLOG_F(loguru::Verbosity_INFO, "mm2 is initialized");
487501
dispatcher_.trigger<mm2_initialized>();

0 commit comments

Comments
 (0)