forked from retoor/devplacepy
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0650c697eb | ||
|
|
3d7b655a45 |
@@ -37,9 +37,10 @@ from devplacepy.cli.backups import (
|
|||||||
)
|
)
|
||||||
from devplacepy.cli.containers import (
|
from devplacepy.cli.containers import (
|
||||||
cmd_containers_list,
|
cmd_containers_list,
|
||||||
cmd_containers_reconcile,
|
|
||||||
cmd_containers_prune,
|
cmd_containers_prune,
|
||||||
cmd_containers_prune_builds,
|
cmd_containers_prune_builds,
|
||||||
|
cmd_containers_prune_stopped,
|
||||||
|
cmd_containers_reconcile,
|
||||||
cmd_containers_gc_workspaces,
|
cmd_containers_gc_workspaces,
|
||||||
)
|
)
|
||||||
from devplacepy.cli.migrate import cmd_emoji_sync, cmd_migrate_data
|
from devplacepy.cli.migrate import cmd_emoji_sync, cmd_migrate_data
|
||||||
@@ -83,6 +84,7 @@ __all__ = [
|
|||||||
"cmd_containers_reconcile",
|
"cmd_containers_reconcile",
|
||||||
"cmd_containers_prune",
|
"cmd_containers_prune",
|
||||||
"cmd_containers_prune_builds",
|
"cmd_containers_prune_builds",
|
||||||
|
"cmd_containers_prune_stopped",
|
||||||
"cmd_containers_gc_workspaces",
|
"cmd_containers_gc_workspaces",
|
||||||
"cmd_emoji_sync",
|
"cmd_emoji_sync",
|
||||||
"cmd_migrate_data",
|
"cmd_migrate_data",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# retoor <retoor@molodetz.nl>
|
# retoor <retoor@molodetz.nl>
|
||||||
|
|
||||||
|
import asyncio
|
||||||
from devplacepy.cli._shared import _audit_cli
|
from devplacepy.cli._shared import _audit_cli
|
||||||
|
|
||||||
|
|
||||||
@@ -18,7 +19,6 @@ def cmd_containers_list(args):
|
|||||||
|
|
||||||
|
|
||||||
def cmd_containers_reconcile(args):
|
def cmd_containers_reconcile(args):
|
||||||
import asyncio
|
|
||||||
from devplacepy.services.containers.service import ContainerService
|
from devplacepy.services.containers.service import ContainerService
|
||||||
|
|
||||||
asyncio.run(ContainerService().run_once())
|
asyncio.run(ContainerService().run_once())
|
||||||
@@ -27,7 +27,6 @@ def cmd_containers_reconcile(args):
|
|||||||
|
|
||||||
|
|
||||||
def cmd_containers_prune(args):
|
def cmd_containers_prune(args):
|
||||||
import asyncio
|
|
||||||
from devplacepy.services.containers.runtime import get_backend
|
from devplacepy.services.containers.runtime import get_backend
|
||||||
from devplacepy.services.containers.service import ContainerService
|
from devplacepy.services.containers.service import ContainerService
|
||||||
|
|
||||||
@@ -66,6 +65,29 @@ def cmd_containers_prune_builds(args):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def cmd_containers_prune_stopped(args):
|
||||||
|
from devplacepy.services.containers import api, store
|
||||||
|
from devplacepy.services.containers.service import ContainerService
|
||||||
|
|
||||||
|
async def run():
|
||||||
|
instances = store.all_instances()
|
||||||
|
marked = 0
|
||||||
|
for inst in instances:
|
||||||
|
if inst["status"] == store.ST_STOPPED and inst["desired_state"] == store.DESIRED_STOPPED:
|
||||||
|
api.mark_for_removal(inst, actor=("system", "prune-stopped"))
|
||||||
|
marked += 1
|
||||||
|
if marked:
|
||||||
|
await ContainerService().run_once()
|
||||||
|
return marked
|
||||||
|
|
||||||
|
marked = asyncio.run(run())
|
||||||
|
_audit_cli("cli.containers.prune_stopped", f"CLI removed {marked} stale stopped container(s)", metadata={"count": marked})
|
||||||
|
if marked:
|
||||||
|
print(f"Prune stopped: marked {marked} container(s) for removal and reconciled.")
|
||||||
|
else:
|
||||||
|
print("No stopped containers to prune.")
|
||||||
|
|
||||||
|
|
||||||
def cmd_containers_gc_workspaces(args):
|
def cmd_containers_gc_workspaces(args):
|
||||||
import shutil
|
import shutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -102,6 +124,9 @@ def register_containers(subparsers):
|
|||||||
"prune-builds",
|
"prune-builds",
|
||||||
help="Remove legacy per-project images and clear the dockerfiles/builds tables",
|
help="Remove legacy per-project images and clear the dockerfiles/builds tables",
|
||||||
).set_defaults(func=cmd_containers_prune_builds)
|
).set_defaults(func=cmd_containers_prune_builds)
|
||||||
|
containers_sub.add_parser(
|
||||||
|
"prune-stopped", help="Remove all stopped containers (completed purpose)"
|
||||||
|
).set_defaults(func=cmd_containers_prune_stopped)
|
||||||
containers_sub.add_parser(
|
containers_sub.add_parser(
|
||||||
"gc-workspaces", help="Remove workspace dirs with no instances"
|
"gc-workspaces", help="Remove workspace dirs with no instances"
|
||||||
).set_defaults(func=cmd_containers_gc_workspaces)
|
).set_defaults(func=cmd_containers_gc_workspaces)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ from .comments import _drop_blocked, _build_comment_items, load_comments, get_re
|
|||||||
from .content import resolve_by_slug, resolve_object_url, get_uids_by_username_match, text_search_clause, get_daily_topic, get_featured_news
|
from .content import resolve_by_slug, resolve_object_url, get_uids_by_username_match, text_search_clause, get_daily_topic, get_featured_news
|
||||||
from .attachments_data import get_attachments, get_attachments_by_type, get_news_images_by_uids, delete_attachment_record, delete_attachments, _delete_attachment_file, get_user_media, get_deleted_media
|
from .attachments_data import get_attachments, get_attachments_by_type, get_news_images_by_uids, delete_attachment_record, delete_attachments, _delete_attachment_file, get_user_media, get_deleted_media
|
||||||
from .stats import _stats_cache, get_site_stats, _analytics_cache, get_platform_analytics, _gist_languages_cache, get_gist_languages
|
from .stats import _stats_cache, get_site_stats, _analytics_cache, get_platform_analytics, _gist_languages_cache, get_gist_languages
|
||||||
from .schema import init_db, _refresh_query_planner_stats, OLD_GATEWAY_URL, migrate_ai_gateway_settings, backfill_api_keys, _backfill_gamification
|
from .schema import BUG_TABLE_RENAMES, migrate_bug_tables_to_issue_tables, init_db, _refresh_query_planner_stats, OLD_GATEWAY_URL, migrate_ai_gateway_settings, backfill_api_keys, _backfill_gamification
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"dataset",
|
"dataset",
|
||||||
@@ -222,6 +222,8 @@ __all__ = [
|
|||||||
"get_platform_analytics",
|
"get_platform_analytics",
|
||||||
"_gist_languages_cache",
|
"_gist_languages_cache",
|
||||||
"get_gist_languages",
|
"get_gist_languages",
|
||||||
|
"BUG_TABLE_RENAMES",
|
||||||
|
"migrate_bug_tables_to_issue_tables",
|
||||||
"init_db",
|
"init_db",
|
||||||
"_refresh_query_planner_stats",
|
"_refresh_query_planner_stats",
|
||||||
"OLD_GATEWAY_URL",
|
"OLD_GATEWAY_URL",
|
||||||
|
|||||||
@@ -6,6 +6,30 @@ from .soft_delete import SOFT_DELETE_TABLES, ensure_soft_delete_columns
|
|||||||
from .ranking import _authors_cache
|
from .ranking import _authors_cache
|
||||||
|
|
||||||
|
|
||||||
|
BUG_TABLE_RENAMES = (
|
||||||
|
("bug_tickets", "issue_tickets"),
|
||||||
|
("bug_comment_authors", "issue_comment_authors"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def migrate_bug_tables_to_issue_tables() -> None:
|
||||||
|
for source_name, destination_name in BUG_TABLE_RENAMES:
|
||||||
|
if source_name not in db.tables:
|
||||||
|
continue
|
||||||
|
source = db[source_name]
|
||||||
|
destination = get_table(destination_name)
|
||||||
|
copied = 0
|
||||||
|
for row in source.all():
|
||||||
|
payload = {key: value for key, value in row.items() if key != "id"}
|
||||||
|
destination.insert_ignore(payload, ["uid"])
|
||||||
|
copied += 1
|
||||||
|
logger.info(
|
||||||
|
"Migrated %s rows from %s into %s", copied, source_name, destination_name
|
||||||
|
)
|
||||||
|
source.drop()
|
||||||
|
logger.info("Dropped table %s after migration", source_name)
|
||||||
|
|
||||||
|
|
||||||
def init_db():
|
def init_db():
|
||||||
tables = db.tables
|
tables = db.tables
|
||||||
_index(db, "users", "idx_users_username", ["username"])
|
_index(db, "users", "idx_users_username", ["username"])
|
||||||
@@ -332,6 +356,7 @@ def init_db():
|
|||||||
_index(
|
_index(
|
||||||
db, "issue_comment_authors", "idx_issue_comment_authors_number", ["gitea_number"]
|
db, "issue_comment_authors", "idx_issue_comment_authors_number", ["gitea_number"]
|
||||||
)
|
)
|
||||||
|
migrate_bug_tables_to_issue_tables()
|
||||||
_index(db, "service_state", "idx_service_state_name", ["name"])
|
_index(db, "service_state", "idx_service_state_name", ["name"])
|
||||||
if "devii_conversations" in db.tables:
|
if "devii_conversations" in db.tables:
|
||||||
conversations = get_table("devii_conversations")
|
conversations = get_table("devii_conversations")
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ instead of the gateway. Before the reconciler has recorded a gateway, the proxy
|
|||||||
|
|
||||||
The service tile on `/admin/services` shows instance counts; per-instance aggregates (CPU/memory, p95
|
The service tile on `/admin/services` shows instance counts; per-instance aggregates (CPU/memory, p95
|
||||||
runtime) are computed on read over the ring buffer. The CLI exposes
|
runtime) are computed on read over the ring buffer. The CLI exposes
|
||||||
`devplace containers list | reconcile | prune | prune-builds | gc-workspaces` (`prune-builds` is a
|
`devplace containers list | reconcile | prune | prune-builds | prune-stopped | gc-workspaces` (`prune-builds` is a
|
||||||
one-time cleanup that removes legacy per-project images and the old dockerfiles/builds tables). Devii's
|
one-time cleanup that removes legacy per-project images and the old dockerfiles/builds tables). Devii's
|
||||||
admin `container_*` tools cover the same instance operations in natural language.
|
admin `container_*` tools cover the same instance operations in natural language.
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,8 +1,24 @@
|
|||||||
2026-07-19T17:34:12 INFO logging initialised at /workspace/repo/dpc.log
|
2026-07-19T09:32:07 INFO logging initialised at /workspace/repo/dpc.log
|
||||||
2026-07-19T17:34:12 DEBUG model=molodetz-pro fps=30
|
2026-07-19T09:32:07 DEBUG model=molodetz-pro fps=30
|
||||||
2026-07-19T17:34:12 INFO read task from file: /workspace/prompts/research-9.txt
|
2026-07-19T09:32:07 INFO read task from file: /workspace/prompts/research-1.txt
|
||||||
2026-07-19T17:34:12 INFO settings merged: model=<default> allow=0 deny=0 ask=0
|
2026-07-19T09:32:07 INFO settings merged: model=<default> allow=0 deny=0 ask=0
|
||||||
2026-07-19T17:38:50 INFO logging initialised at /workspace/repo/dpc.log
|
2026-07-19T15:54:39 INFO logging initialised at /workspace/repo/dpc.log
|
||||||
2026-07-19T17:38:50 DEBUG model=molodetz-pro fps=30
|
2026-07-19T15:54:39 DEBUG model=molodetz-pro fps=30
|
||||||
2026-07-19T17:38:50 INFO read task from file: /workspace/prompts/execution-1.txt
|
2026-07-19T15:54:39 INFO read task from file: /workspace/prompts/research-2.txt
|
||||||
2026-07-19T17:38:50 INFO settings merged: model=<default> allow=0 deny=0 ask=0
|
2026-07-19T15:54:39 INFO settings merged: model=<default> allow=0 deny=0 ask=0
|
||||||
|
2026-07-19T17:25:31 INFO logging initialised at /workspace/repo/dpc.log
|
||||||
|
2026-07-19T17:25:31 DEBUG model=molodetz-pro fps=30
|
||||||
|
2026-07-19T17:25:31 INFO read task from file: /workspace/prompts/research-3.txt
|
||||||
|
2026-07-19T17:25:31 INFO settings merged: model=<default> allow=0 deny=0 ask=0
|
||||||
|
2026-07-19T17:37:32 INFO logging initialised at /workspace/repo/dpc.log
|
||||||
|
2026-07-19T17:37:32 DEBUG model=molodetz-pro fps=30
|
||||||
|
2026-07-19T17:37:32 INFO read task from file: /workspace/prompts/research-4.txt
|
||||||
|
2026-07-19T17:37:32 INFO settings merged: model=<default> allow=0 deny=0 ask=0
|
||||||
|
2026-07-19T18:22:18 INFO logging initialised at /workspace/repo/dpc.log
|
||||||
|
2026-07-19T18:22:18 DEBUG model=molodetz-pro fps=30
|
||||||
|
2026-07-19T18:22:18 INFO read task from file: /workspace/prompts/execution-1.txt
|
||||||
|
2026-07-19T18:22:18 INFO settings merged: model=<default> allow=0 deny=0 ask=0
|
||||||
|
2026-07-19T18:49:24 INFO logging initialised at /workspace/repo/dpc.log
|
||||||
|
2026-07-19T18:49:24 DEBUG model=molodetz-pro fps=30
|
||||||
|
2026-07-19T18:49:24 INFO read task from file: /workspace/prompts/execution-2.txt
|
||||||
|
2026-07-19T18:49:24 INFO settings merged: model=<default> allow=0 deny=0 ask=0
|
||||||
|
|||||||
Reference in New Issue
Block a user