40
44
bool hasInstances() override;
47
/** Pointer to the registry so we can ask it for things */
43
48
std::shared_ptr<Registry> _registry;
50
static std::list<std::pair<std::string, std::string>> confinedEnv(const std::string& package,
51
const std::string& pkgdir);
54
/** An object that represents an instance of a job on Upstart. This
55
then implements everything needed by the instance interface. Most
56
applications tie into this today and use it as the backend for
46
58
class UpstartInstance : public Application::Instance
49
61
explicit UpstartInstance(const AppID& appId,
50
62
const std::string& job,
51
63
const std::string& instance,
64
const std::vector<Application::URL>& urls,
52
65
const std::shared_ptr<Registry>& registry);
54
67
/* Query lifecycle */
67
80
void setOomAdjustment(const oom::Score score) override;
68
81
const oom::Score getOomAdjustment() override;
70
/* Creating by launch */
83
/** Flag for whether we should include the testing environment variables */
71
84
enum class launchMode
86
STANDARD, /**< Standard variable set */
87
TEST /**< Include testing environment vars */
76
static std::shared_ptr<UpstartInstance> launch(const AppID& appId,
77
const std::string& job,
78
const std::string& instance,
79
const std::vector<Application::URL>& urls,
80
const std::shared_ptr<Registry>& registry,
89
static std::shared_ptr<UpstartInstance> launch(
91
const std::string& job,
92
const std::string& instance,
93
const std::vector<Application::URL>& urls,
94
const std::shared_ptr<Registry>& registry,
96
std::function<std::list<std::pair<std::string, std::string>>(void)>& getenv);
84
100
const AppID appId_;
101
/** Upstart job name */
85
102
const std::string job_;
103
/** Instance ID environment value, empty if none */
86
104
const std::string instance_;
105
/** The URLs that this was launched for. Only valid on launched jobs, we
106
should look at perhaps changing that. */
107
std::vector<Application::URL> urls_;
108
/** A link to the registry we're using for connections */
87
109
std::shared_ptr<Registry> registry_;
89
111
std::vector<pid_t> forAllPids(std::function<void(pid_t)> eachPid);
92
114
void oomValueToPid(pid_t pid, const oom::Score oomvalue);
93
115
void oomValueToPidHelper(pid_t pid, const oom::Score oomvalue);
94
116
void pidListToDbus(const std::vector<pid_t>& pids, const std::string& signal);
118
static std::shared_ptr<gchar*> urlsToStrv(const std::vector<Application::URL>& urls);
119
static void application_start_cb(GObject* obj, GAsyncResult* res, gpointer user_data);
97
122
} // namespace app_impls