/* * Copyright © 2016 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Authors: * Ted Gould */ #pragma once #include "jobs-base.h" #include #include #include #include #include #include #include #include namespace lomiri { namespace app_launch { namespace jobs { namespace manager { class POSIX : public Base { public: POSIX(const std::shared_ptr& registry); virtual ~POSIX(); virtual std::shared_ptr launch( const AppID& appId, const std::string& job, const std::string& instance, const std::vector& urls, launchMode mode, std::function>(void)>& getenv) override; virtual std::shared_ptr existing(const AppID& appId, const std::string& job, const std::string& instance, const std::vector& urls) override; virtual std::list runningAppIds(const std::list& jobs) override; virtual std::vector> instances(const AppID& appID, const std::string& job) override; virtual core::Signal& jobStarted() override; virtual core::Signal& jobStopped() override; virtual core::Signal& jobFailed() override; pid_t unitPrimaryPid(const AppID& appId, const std::string& job, const std::string& instance); std::vector unitPids(const AppID& appId, const std::string& job, const std::string& instance); void stopUnit(const AppID& appId, const std::string& job, const std::string& instance); private: std::vector launchedpids; // std::string cgroup_root_; // // /** Connection to the User DBus bus */ // std::shared_ptr userbus_; // /** Setup the bus and all the details in it */ // void setupUserbus(const std::shared_ptr& reg); // core::Signal sig_jobStarted; core::Signal sig_jobStopped; core::Signal sig_jobFailed; // // ManagedDBusSignalConnection handle_unitNew; /**< GDBus signal watcher handle for the unit new signal */ // ManagedDBusSignalConnection handle_unitRemoved; /**< GDBus signal watcher handle for the unit removed signal */ // ManagedDBusSignalConnection handle_appFailed; /**< GDBus signal watcher handle for app failed signal */ // // bool noResetUnits_{false}; /**< Debug flag to avoid resetting the systemd units */ // // std::once_flag // flag_appFailed; /**< Variable to track to see if signal handlers are installed for application failed */ // // struct UnitInfo // { // std::string appid; // std::string job; // std::string inst; // // bool operator<(const UnitInfo& b) const // { // if (job != b.job) // return job < b.job; // // if (appid != b.appid) // return appid < b.appid; // // return inst < b.inst; // } // }; // // void getInitialUnits(const std::shared_ptr& bus, const std::shared_ptr& cancel); // // struct UnitData // { // std::string jobpath; // std::string unitpath; // }; // // std::map> unitPaths; // UnitInfo parseUnit(const std::string& unit) const; // std::string unitName(const UnitInfo& info) const; // std::string unitPath(const UnitInfo& info); // // UnitInfo unitNew(const std::string& name, const std::string& path, const std::shared_ptr& bus); // void unitRemoved(const std::string& name, const std::string& path); // static std::string findEnv(const std::string& value, std::list>& env); static void removeEnv(const std::string& value, std::list>& env); static void copyEnv(const std::string& envname, std::list>& env); static void copyEnvByPrefix(const std::string& prefix, std::list>& env); static int envSize(std::list>& env); static std::vector parseExec(std::list>& env); // static void application_start_cb(GObject* obj, GAsyncResult* res, gpointer user_data); // // void resetUnit(const UnitInfo& info); }; } // namespace manager } // namespace jobs } // namespace app_launch } // namespace lomiri