This file is indexed.

/usr/lib/python3/dist-packages/maasserver/server.py is in python3-django-maas 2.4.0~beta2-6865-gec43e47e6-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Copyright 2018 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

"""Entrypoint for the maas regiond service."""

import argparse
import os
import signal
import sys

# Set the default so on installed system running regiond directly just works.
os.environ.setdefault(
    "DJANGO_SETTINGS_MODULE", "maasserver.djangosettings.settings")


def runMasterServices():
    """Run the maas-regiond master services."""
    from provisioningserver.server import runService
    runService("maas-regiond-master")


def runAllInOneServices():
    """Run the maas-regiond all-in-one services."""
    from provisioningserver.server import runService
    runService("maas-regiond-all")


def runWorkerServices():
    """Run the worker service."""
    from provisioningserver.server import runService
    runService("maas-regiond-worker")


def parse():
    """Parse the command-line arguments."""
    parser = argparse.ArgumentParser(
        description='MAAS region controller process')
    parser.add_argument(
        '-d', '--debug', action='store_true', help=(
            "Run in debug mode. Doesn't fork and keeps all services "
            "in the spawned process."))
    parser.add_argument(
        '-w', '--workers', metavar='N', type=int, help=(
            "Number of worker process to spawn."))
    return parser.parse_args()


def run():
    """Run the maas-regiond master service.

    Spawns children workers up to the number of CPU's minimum is 4 workers.
    """
    args = parse()

    # Remove all the command line arguments, so they don't interfere with
    # the twistd argument parser.
    sys.argv = sys.argv[:1]

    # Workers are spawned with environment so it knows that it would only
    # be a worker.
    if os.environ.get('MAAS_REGIOND_PROCESS_MODE') == 'worker':
        # Ignore interrupt on the workers. The master will kill them directly.
        signal.signal(signal.SIGINT, signal.SIG_IGN)
        runWorkerServices()
        return

    # Circular imports.
    from maasserver.workers import set_max_workers_count

    # Debug mode, run the all-in-one mode.
    if args.debug:
        set_max_workers_count(1)
        runAllInOneServices()
        return

    # Calculate the number of workers.
    worker_count = args.workers
    if not worker_count:
        from maasserver.config import RegionConfiguration
        try:
            with RegionConfiguration.open() as config:
                worker_count = config.num_workers
        except:
            worker_count = 4
    if worker_count <= 0:
        raise ValueError('Number of workers must be greater than zero.')

    # Set the maximum number of workers.
    set_max_workers_count(worker_count)

    # Start the master services, which will spawn the required workers.
    runMasterServices()