plain.dev 0.27.0__tar.gz → 0.28.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {plain_dev-0.27.0 → plain_dev-0.28.0}/PKG-INFO +1 -1
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/cli.py +48 -28
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/contribute/cli.py +1 -1
- {plain_dev-0.27.0 → plain_dev-0.28.0}/pyproject.toml +1 -1
- {plain_dev-0.27.0 → plain_dev-0.28.0}/.gitignore +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/LICENSE +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/README.md +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/README.md +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/__init__.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/contribute/README.md +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/contribute/__init__.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/debug.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/default_settings.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/entrypoints.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/gunicorn_logging.json +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/mkcert.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/pdb.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/poncho/__init__.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/poncho/color.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/poncho/compat.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/poncho/manager.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/poncho/printer.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/poncho/process.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/precommit/__init__.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/precommit/cli.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/requests.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/services.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/templates/dev/requests.html +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/urls.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/utils.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/plain/dev/views.py +0 -0
- {plain_dev-0.27.0 → plain_dev-0.28.0}/tests/settings.py +0 -0
@@ -1,11 +1,11 @@
|
|
1
1
|
import importlib
|
2
2
|
import json
|
3
|
+
import multiprocessing
|
3
4
|
import os
|
4
5
|
import platform
|
5
6
|
import signal
|
6
7
|
import subprocess
|
7
8
|
import sys
|
8
|
-
import threading
|
9
9
|
import time
|
10
10
|
import tomllib
|
11
11
|
from importlib.metadata import entry_points
|
@@ -223,21 +223,16 @@ class Dev:
|
|
223
223
|
# If plain.models is installed (common) then we
|
224
224
|
# will do a couple extra things before starting all of the app-related
|
225
225
|
# processes (this way they don't all have to db-wait or anything)
|
226
|
+
process = None
|
226
227
|
if find_spec("plain.models") is not None:
|
227
228
|
# Use a custom signal to tell the main thread to add
|
228
229
|
# the app processes once the db is ready
|
229
230
|
signal.signal(signal.SIGUSR1, self.start_app)
|
230
231
|
|
231
|
-
|
232
|
-
|
233
|
-
subprocess.run(["plain", "migrate", "--backup"], env=env, check=True)
|
234
|
-
# preflight with db?
|
235
|
-
os.kill(os.getpid(), signal.SIGUSR1)
|
236
|
-
|
237
|
-
thread = threading.Thread(
|
238
|
-
target=_thread, daemon=True, args=(self.plain_env,)
|
232
|
+
process = multiprocessing.Process(
|
233
|
+
target=_process_task, args=(self.plain_env,)
|
239
234
|
)
|
240
|
-
|
235
|
+
process.start()
|
241
236
|
else:
|
242
237
|
# Start the app processes immediately
|
243
238
|
self.start_app(None, None)
|
@@ -253,6 +248,14 @@ class Dev:
|
|
253
248
|
if services_pid:
|
254
249
|
services_pid.rm()
|
255
250
|
|
251
|
+
# Make sure the process is terminated if it is still running
|
252
|
+
if process and process.is_alive():
|
253
|
+
os.killpg(os.getpgid(process.pid), signal.SIGTERM)
|
254
|
+
process.join(timeout=3)
|
255
|
+
if process.is_alive():
|
256
|
+
os.killpg(os.getpgid(process.pid), signal.SIGKILL)
|
257
|
+
process.join()
|
258
|
+
|
256
259
|
return self.poncho.returncode
|
257
260
|
|
258
261
|
def start_app(self, signum, frame):
|
@@ -349,24 +352,26 @@ class Dev:
|
|
349
352
|
sys.exit(1)
|
350
353
|
|
351
354
|
def set_csrf_and_allowed_hosts(self):
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
self.custom_process_env["PLAIN_ALLOWED_HOSTS"] = allowed_hosts
|
355
|
+
if "PLAIN_CSRF_TRUSTED_ORIGINS" not in os.environ:
|
356
|
+
csrf_trusted_origins = json.dumps(
|
357
|
+
[
|
358
|
+
self.url,
|
359
|
+
]
|
360
|
+
)
|
361
|
+
self.plain_env["PLAIN_CSRF_TRUSTED_ORIGINS"] = csrf_trusted_origins
|
362
|
+
self.custom_process_env["PLAIN_CSRF_TRUSTED_ORIGINS"] = csrf_trusted_origins
|
363
|
+
click.secho(
|
364
|
+
f"Automatically set PLAIN_CSRF_TRUSTED_ORIGINS={csrf_trusted_origins}",
|
365
|
+
dim=True,
|
366
|
+
)
|
365
367
|
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
368
|
+
if "PLAIN_ALLOWED_HOSTS" not in os.environ:
|
369
|
+
allowed_hosts = json.dumps([self.hostname])
|
370
|
+
self.plain_env["PLAIN_ALLOWED_HOSTS"] = allowed_hosts
|
371
|
+
self.custom_process_env["PLAIN_ALLOWED_HOSTS"] = allowed_hosts
|
372
|
+
click.secho(
|
373
|
+
f"Automatically set PLAIN_ALLOWED_HOSTS={allowed_hosts}", dim=True
|
374
|
+
)
|
370
375
|
|
371
376
|
def run_preflight(self):
|
372
377
|
click.echo()
|
@@ -379,7 +384,9 @@ class Dev:
|
|
379
384
|
extra_watch_files = []
|
380
385
|
for f in os.listdir(APP_PATH.parent):
|
381
386
|
if f.startswith(".env"):
|
382
|
-
|
387
|
+
# Needs to be absolute or "./" for inotify to work on Linux...
|
388
|
+
# https://github.com/dropseed/plain/issues/26
|
389
|
+
extra_watch_files.append(str(Path(APP_PATH.parent) / f))
|
383
390
|
|
384
391
|
reload_extra = " ".join(f"--reload-extra-file {f}" for f in extra_watch_files)
|
385
392
|
gunicorn_cmd = [
|
@@ -437,3 +444,16 @@ class Dev:
|
|
437
444
|
**data.get("env", {}),
|
438
445
|
}
|
439
446
|
self.poncho.add_process(name, data["cmd"], env=env)
|
447
|
+
|
448
|
+
|
449
|
+
def _process_task(env):
|
450
|
+
# Make this process the leader of a new group which can be killed together if it doesn't finish
|
451
|
+
os.setsid()
|
452
|
+
|
453
|
+
subprocess.run(["plain", "models", "db-wait"], env=env, check=True)
|
454
|
+
subprocess.run(["plain", "migrate", "--backup"], env=env, check=True)
|
455
|
+
|
456
|
+
# preflight with db?
|
457
|
+
|
458
|
+
# Send SIGUSR1 to the parent process so the parent's handler is invoked
|
459
|
+
os.kill(os.getppid(), signal.SIGUSR1)
|
@@ -8,7 +8,7 @@ from plain.cli import register_cli
|
|
8
8
|
|
9
9
|
|
10
10
|
@register_cli("contrib")
|
11
|
-
@click.command("contribute")
|
11
|
+
@click.command("contribute", hidden=True)
|
12
12
|
@click.option("--repo", default="../plain", help="Path to the plain repo")
|
13
13
|
@click.option(
|
14
14
|
"--reset", is_flag=True, help="Undo any changes to pyproject.toml and uv.lock"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|