MCPcopy
hub / github.com/benoitc/gunicorn / start

Method start

gunicorn/arbiter.py:141–199  ·  view source on GitHub ↗

\ Initialize the arbiter. Start listening and set pidfile if needed.

(self)

Source from the content-addressed store, hash-verified

139 self.app.wsgi()
140
141 def start(self):
142 """\
143 Initialize the arbiter. Start listening and set pidfile if needed.
144 """
145 self.log.info("Starting gunicorn %s", __version__)
146
147 # Initialize stats tracking
148 self._stats['start_time'] = time.time()
149
150 if 'GUNICORN_PID' in os.environ:
151 self.master_pid = int(os.environ.get('GUNICORN_PID'))
152 self.proc_name = self.proc_name + ".2"
153 self.master_name = "Master.2"
154
155 self.pid = os.getpid()
156 if self.cfg.pidfile is not None:
157 pidname = self.cfg.pidfile
158 if self.master_pid != 0:
159 pidname += ".2"
160 self.pidfile = Pidfile(pidname)
161 self.pidfile.create(self.pid)
162 self.cfg.on_starting(self)
163
164 self.init_signals()
165
166 if not self.LISTENERS:
167 fds = None
168 listen_fds = systemd.listen_fds()
169 if listen_fds:
170 self.systemd = True
171 fds = range(systemd.SD_LISTEN_FDS_START,
172 systemd.SD_LISTEN_FDS_START + listen_fds)
173
174 elif self.master_pid:
175 fds = []
176 for fd in os.environ.pop('GUNICORN_FD').split(','):
177 fds.append(int(fd))
178
179 if not (self.cfg.reuse_port and hasattr(socket, 'SO_REUSEPORT')):
180 self.LISTENERS = sock.create_sockets(self.cfg, self.log, fds)
181
182 listeners_str = ",".join([str(lnr) for lnr in self.LISTENERS])
183 self.log.debug("Arbiter booted")
184 self.log.info("Listening at: %s (%s)", listeners_str, self.pid)
185 self.log.info("Using worker: %s", self.cfg.worker_class_str)
186 systemd.sd_notify("READY=1\nSTATUS=Gunicorn arbiter booted", self.log)
187
188 # check worker class requirements
189 if hasattr(self.worker_class, "check_config"):
190 self.worker_class.check_config(self.cfg, self.log)
191
192 # Start dirty arbiter if configured
193 if self.cfg.dirty_workers > 0 and self.cfg.dirty_apps:
194 self.spawn_dirty_arbiter()
195
196 # Note: control socket server is started after initial workers spawn
197 # to avoid fork deadlocks with asyncio
198

Callers 12

runMethod · 0.95
_start_control_serverMethod · 0.45
when_readyFunction · 0.45
tornadoapp.pyFile · 0.45
__init__Method · 0.45

Calls 10

init_signalsMethod · 0.95
spawn_dirty_arbiterMethod · 0.95
PidfileClass · 0.90
createMethod · 0.80
on_startingMethod · 0.80
when_readyMethod · 0.80
infoMethod · 0.45
getMethod · 0.45
debugMethod · 0.45
check_configMethod · 0.45