Home | History | Annotate | Download | only in init

Lines Matching refs:Service

17 #include "service.h"
62 Service::Service(const std::string& name, const std::string& classname,
70 Service::Service(const std::string& name, const std::string& classname,
79 void Service::NotifyStateChange(const std::string& new_state) const {
96 bool Service::Reap() {
98 NOTICE("Service '%s' (pid %d) killing any children in process group\n",
148 // Execute all onrestart commands for this service.
155 void Service::DumpState() const {
156 INFO("service %s\n", name_.c_str());
168 bool Service::HandleClass(const std::vector<std::string>& args, std::string* err) {
173 bool Service::HandleConsole(const std::vector<std::string>& args, std::string* err) {
178 bool Service::HandleCritical(const std::vector<std::string>& args, std::string* err) {
183 bool Service::HandleDisabled(const std::vector<std::string>& args, std::string* err) {
189 bool Service::HandleGroup(const std::vector<std::string>& args, std::string* err) {
197 bool Service::HandleIoprio(const std::vector<std::string>& args, std::string* err) {
219 bool Service::HandleKeycodes(const std::vector<std::string>& args, std::string* err) {
226 bool Service::HandleOneshot(const std::vector<std::string>& args, std::string* err) {
231 bool Service::HandleOnrestart(const std::vector<std::string>& args, std::string* err) {
237 bool Service::HandleSeclabel(const std::vector<std::string>& args, std::string* err) {
242 bool Service::HandleSetenv(const std::vector<std::string>& args, std::string* err) {
248 bool Service::HandleSocket(const std::vector<std::string>& args, std::string* err) {
263 bool Service::HandleUser(const std::vector<std::string>& args, std::string* err) {
268 bool Service::HandleWritepid(const std::vector<std::string>& args, std::string* err) {
273 class Service::OptionHandlerMap : public KeywordMap<OptionHandler> {
281 Service::OptionHandlerMap::Map& Service::OptionHandlerMap::map() const {
284 {"class", {1, 1, &Service::HandleClass}},
285 {"console", {0, 0, &Service::HandleConsole}},
286 {"critical", {0, 0, &Service::HandleCritical}},
287 {"disabled", {0, 0, &Service::HandleDisabled}},
288 {"group", {1, NR_SVC_SUPP_GIDS + 1, &Service::HandleGroup}},
289 {"ioprio", {2, 2, &Service::HandleIoprio}},
290 {"keycodes", {1, kMax, &Service::HandleKeycodes}},
291 {"oneshot", {0, 0, &Service::HandleOneshot}},
292 {"onrestart", {1, kMax, &Service::HandleOnrestart}},
293 {"seclabel", {1, 1, &Service::HandleSeclabel}},
294 {"setenv", {2, 2, &Service::HandleSetenv}},
295 {"socket", {3, 6, &Service::HandleSocket}},
296 {"user", {1, 1, &Service::HandleUser}},
297 {"writepid", {1, kMax, &Service::HandleWritepid}},
302 bool Service::HandleLine(const std::vector<std::string>& args, std::string* err) {
318 bool Service::Start() {
319 // Starting a service removes it from the disabled or reset state and
333 ERROR("service '%s' requires console\n", name_.c_str());
353 INFO("computing context for service '%s'\n", args_[0].c_str());
375 ERROR("Service %s does not have a SELinux domain defined.\n", name_.c_str());
388 NOTICE("Starting service '%s'...\n", name_.c_str());
495 bool Service::StartIfNotDisabled() {
504 bool Service::Enable() {
512 void Service::Reset() {
516 void Service::Stop() {
520 void Service::Terminate() {
524 NOTICE("Sending SIGTERM to service '%s' (pid %d)...\n", name_.c_str(),
531 void Service::Restart() {
533 /* Stop, wait, then start the service. */
536 /* Just start the service since it's not running. */
538 } /* else: Service is restarting anyways. */
541 void Service::RestartIfNeeded(time_t& process_needs_restart) {
557 void Service::StopOrReset(int how) {
558 /* The service is still SVC_RUNNING until its process exits, but if it has
566 /* if the service has not yet started, prevent
576 NOTICE("Service '%s' is being killed...\n", name_.c_str());
584 void Service::ZapStdio() const {
593 void Service::OpenConsole() const {
605 void Service::PublishSocket(const std::string& name, int fd) const {
624 void ServiceManager::AddService(std::unique_ptr<Service> service) {
625 Service* old_service = FindServiceByName(service->name());
627 ERROR("ignored duplicate definition of service '%s'",
628 service->name().c_str());
631 services_.emplace_back(std::move(service));
634 Service* ServiceManager::MakeExecOneshotService(const std::vector<std::string>& args) {
677 std::unique_ptr<Service> svc_p(new Service(name, "default", flags, uid, gid,
680 ERROR("Couldn't allocate service for exec of '%s'",
684 Service* svc = svc_p.get();
690 Service* ServiceManager::FindServiceByName(const std::string& name) const {
692 [&name] (const std::unique_ptr<Service>& s) {
701 Service* ServiceManager::FindServiceByPid(pid_t pid) const {
703 [&pid] (const std::unique_ptr<Service>& s) {
712 Service* ServiceManager::FindServiceByKeychord(int keychord_id) const {
714 [&keychord_id] (const std::unique_ptr<Service>& s) {
724 void ServiceManager::ForEachService(std::function<void(Service*)> callback) const {
731 void (*func)(Service* svc)) const {
740 void (*func)(Service* svc)) const {
748 void ServiceManager::RemoveService(const Service& svc) {
750 [&svc] (const std::unique_ptr<Service>& s) {
777 Service* svc = FindServiceByPid(pid);
781 name = android::base::StringPrintf("Service '%s' (pid %d)",
823 *err = StringPrintf("invalid service name '%s'", name.c_str());
828 service_ = std::make_unique<Service>(name, "default", str_args);