30#include <ArmarXCore/interface/components/ExternalApplicationManagerInterface.h>
33#pragma GCC diagnostic push
34#pragma GCC diagnostic ignored "-Wunused-result"
35#include <boost/asio.hpp>
36#include <boost/iostreams/device/file_descriptor.hpp>
37#include <boost/iostreams/stream.hpp>
40#pragma GCC diagnostic pop
44#if defined(BOOST_WINDOWS_API)
45using pipe_end = boost::asio::windows::stream_handle;
46#elif defined(BOOST_POSIX_API)
47using pipe_end = boost::asio::posix::stream_descriptor;
81 virtual public armarx::ExternalApplicationManagerInterface
88 return "ExternalApplicationManager";
122 struct StreamMetaData
125 StreamMetaData(
const StreamMetaData&
data);
128 boost::asio::io_service io_service;
129 boost::process::pipe pipe;
131 boost::asio::streambuf input_buffer;
132 boost::iostreams::file_descriptor_sink sink;
133 std::function<void(
const boost::system::error_code& error, std::size_t size)>
read;
135 using StreamMetaDataPtr = std::shared_ptr<struct StreamMetaData>;
139 void updateLogSenderComponentName();
141 void startApplication();
142 void stopApplication();
143 void waitForApplication();
147 bool waitForProcessToFinish(
int pid,
int timeoutMS);
149 void setupStream(StreamMetaData& meta);
154 std::string application;
156 Ice::StringSeq envVars;
157 bool restartWhenCrash;
158 bool disconnectWhenCrash;
159 std::string startUpKeyword;
160 std::string workingDir;
161 bool redirectToArmarXLog;
163 std::unique_ptr<boost::process::child> childProcess;
166 bool appStoppedOnPurpose;
170 boost::iostreams::stream<boost::iostreams::file_descriptor_source> out_stream;
171 StreamMetaDataPtr outMetaData;
173 boost::iostreams::stream<boost::iostreams::file_descriptor_source> err_stream;
174 StreamMetaDataPtr errMetaData;
176 boost::iostreams::file_descriptor_source stdout_source;
177 boost::iostreams::file_descriptor_source stderr_source;
181 std::string starterUUID, depObjUUID;
Defines a child process class.
Default component property definition container.
Baseclass for all ArmarX ManagedIceObjects requiring properties.
ExternalApplicationManagerPropertyDefinitions(std::string prefix)
Executes a given application and keeps track if it is still running.
void onInitComponent() override
void terminateApplication(const Ice::Current &) override
virtual void addApplicationArguments(Ice::StringSeq &args)
void onDisconnectComponent() override
virtual std::string deriveWorkingDir() const
std::string getPathToApplication(const Ice::Current &) override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
bool isApplicationRunning(const Ice::Current &) override
friend struct ExternalApplicationManagerDependency
void onConnectComponent() override
void addDependencyObject()
void onExitComponent() override
virtual std::string getDefaultName() const override
void restartApplication(const Ice::Current &) override
friend struct ExternalApplicationManagerStarter
virtual std::string deriveApplicationPath() const
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
This file offers overloads of toIce() and fromIce() functions for STL container types.
void read(auto &eigen, auto *table)
IceInternal::Handle< ExternalApplicationManagerStarter > ExternalApplicationManagerStarterPtr
IceInternal::Handle< ExternalApplicationManagerDependency > ExternalApplicationManagerDependencyPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Convenience header which includes all public Boost.Process header files.