tree: 597b76caed23b7d80d62adc65050c07a366ed978 [path history] [tgz]
  1. .coveragerc
  2. README.md
  3. __init__.py
  4. __main__.py
  5. cloudtail_factory.py
  6. config_watcher.py
  7. service.py
  8. service_thread.py
  9. test/
  10. version_finder.py
infra/services/service_manager/README.md

Service Manager

The service_manager starts, monitors and stops long-running processes on the machine.

Services are configured with JSON config files in /etc/infra-services. or C:/chrome-infra/service-config on Windows.

Each config file defines one service. A service will be started immediately when its config file is added to that directory, will be stopped when the config is removed, and will be restarted when the config is changed.

The config file contains a JSON object with the following fields:

  • name - A short friendly name for the service.

  • working_directory - (optional) The working directory where a given service starts.

  • cmd - A list with the command to run and arguments for a given service.

  • stop_time - (optional, default 10 seconds) Number of seconds to give the service to shut itself down after receiving a SIGTERM. service_manager will send a SIGKILL after this time if the service is still running.

  • environment - (optional) a dict with a list of environment variables to override: {name: value}. Note that name and value must be a string.

  • resources - (optional) a dict with a list of resource limits in the following format. This field is ignored in windows. { “resource”: [softlimit, hardlimit], “resource1”: [softlimit, hardlimit], “resource2”: [], ... }

                  The following resources are supported in this field, and
                  a value with an empty array indicates that there is no limit
                  for a given resource. To get more information, please visit
                  the following page:
                  https://docs.python.org/2/library/resource.html
    
                  "cpu"           : The maximum amount of processor time
                                    (in seconds).
                  "memory"        : The maximum area (in bytes) of address
                                    space.
                  "num_files"     : The maximum number of open file
                                    descriptors.
                  "num_processes" : The maximum number of processes it may
                                    creates.
                  "stack"         : The maximum size (in bytes) of the call
                                    stack.
    
    • cipd_version_file - Path to a CIPD version file to monitor for changes. The service will be restarted when a new version is detected.

Example:

{
  "name": "mastermon",
  "working_directory": "/opt/infra-python",
  "cmd": [ "/opt/infra-python/run.py", "infra.services.mastermon" ],
  "args": [
    "--url", "http://build.chromium.org/p/chromium",
    "--ts-mon-endpoint", "file:///tmp/metrics"
  ],
  "stop_time": 5
}