hop3-server 0.4.0b1__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.
- hop3_server-0.4.0b1/PKG-INFO +195 -0
- hop3_server-0.4.0b1/README.md +162 -0
- hop3_server-0.4.0b1/pyproject.toml +103 -0
- hop3_server-0.4.0b1/src/hop3/.DS_Store +0 -0
- hop3_server-0.4.0b1/src/hop3/__init__.py +1 -0
- hop3_server-0.4.0b1/src/hop3/alembic/README +1 -0
- hop3_server-0.4.0b1/src/hop3/alembic/env.py +99 -0
- hop3_server-0.4.0b1/src/hop3/alembic/script.py.mako +28 -0
- hop3_server-0.4.0b1/src/hop3/alembic/versions/0d21c362f66d_add_app_state_machine_and_error_message.py +63 -0
- hop3_server-0.4.0b1/src/hop3/alembic/versions/961bfd2ecce5_add_runtime_field_to_app_model.py +37 -0
- hop3_server-0.4.0b1/src/hop3/alembic/versions/d20dd80dafca_initial_schema.py +30 -0
- hop3_server-0.4.0b1/src/hop3/alembic.ini +147 -0
- hop3_server-0.4.0b1/src/hop3/commands/__init__.py +7 -0
- hop3_server-0.4.0b1/src/hop3/commands/_base.py +91 -0
- hop3_server-0.4.0b1/src/hop3/commands/_errors.py +202 -0
- hop3_server-0.4.0b1/src/hop3/commands/admin.py +688 -0
- hop3_server-0.4.0b1/src/hop3/commands/app.py +1145 -0
- hop3_server-0.4.0b1/src/hop3/commands/apps.py +108 -0
- hop3_server-0.4.0b1/src/hop3/commands/auth.py +303 -0
- hop3_server-0.4.0b1/src/hop3/commands/backup.py +442 -0
- hop3_server-0.4.0b1/src/hop3/commands/config.py +818 -0
- hop3_server-0.4.0b1/src/hop3/commands/git.py +170 -0
- hop3_server-0.4.0b1/src/hop3/commands/help.py +186 -0
- hop3_server-0.4.0b1/src/hop3/commands/misc.py +410 -0
- hop3_server-0.4.0b1/src/hop3/commands/services.py +816 -0
- hop3_server-0.4.0b1/src/hop3/commands/system.py +363 -0
- hop3_server-0.4.0b1/src/hop3/config.py +386 -0
- hop3_server-0.4.0b1/src/hop3/core/__init__.py +10 -0
- hop3_server-0.4.0b1/src/hop3/core/backup.py +801 -0
- hop3_server-0.4.0b1/src/hop3/core/credentials.py +122 -0
- hop3_server-0.4.0b1/src/hop3/core/env.py +108 -0
- hop3_server-0.4.0b1/src/hop3/core/events.py +78 -0
- hop3_server-0.4.0b1/src/hop3/core/git.py +111 -0
- hop3_server-0.4.0b1/src/hop3/core/hooks.py +17 -0
- hop3_server-0.4.0b1/src/hop3/core/hookspecs.py +104 -0
- hop3_server-0.4.0b1/src/hop3/core/plugins.py +511 -0
- hop3_server-0.4.0b1/src/hop3/core/protocols.py +510 -0
- hop3_server-0.4.0b1/src/hop3/core/runtime_registry.py +106 -0
- hop3_server-0.4.0b1/src/hop3/deployers/__init__.py +6 -0
- hop3_server-0.4.0b1/src/hop3/deployers/deployer.py +189 -0
- hop3_server-0.4.0b1/src/hop3/deployers/git_based_deployer.py +204 -0
- hop3_server-0.4.0b1/src/hop3/di/__init__.py +36 -0
- hop3_server-0.4.0b1/src/hop3/di/container.py +113 -0
- hop3_server-0.4.0b1/src/hop3/di/providers.py +100 -0
- hop3_server-0.4.0b1/src/hop3/lib/__init__.py +14 -0
- hop3_server-0.4.0b1/src/hop3/lib/archives.py +197 -0
- hop3_server-0.4.0b1/src/hop3/lib/backports.py +56 -0
- hop3_server-0.4.0b1/src/hop3/lib/config.py +169 -0
- hop3_server-0.4.0b1/src/hop3/lib/console.py +394 -0
- hop3_server-0.4.0b1/src/hop3/lib/datetime.py +16 -0
- hop3_server-0.4.0b1/src/hop3/lib/decorators.py +10 -0
- hop3_server-0.4.0b1/src/hop3/lib/freeze.py +40 -0
- hop3_server-0.4.0b1/src/hop3/lib/logging.py +199 -0
- hop3_server-0.4.0b1/src/hop3/lib/multi_tail.py +136 -0
- hop3_server-0.4.0b1/src/hop3/lib/path.py +35 -0
- hop3_server-0.4.0b1/src/hop3/lib/registry.py +87 -0
- hop3_server-0.4.0b1/src/hop3/lib/scanner.py +36 -0
- hop3_server-0.4.0b1/src/hop3/lib/settings.py +67 -0
- hop3_server-0.4.0b1/src/hop3/lib/sysinfo.py +260 -0
- hop3_server-0.4.0b1/src/hop3/lib/templating.py +27 -0
- hop3_server-0.4.0b1/src/hop3/lib/types.py +12 -0
- hop3_server-0.4.0b1/src/hop3/lib/util.py +199 -0
- hop3_server-0.4.0b1/src/hop3/orm/__init__.py +30 -0
- hop3_server-0.4.0b1/src/hop3/orm/addon_credential.py +86 -0
- hop3_server-0.4.0b1/src/hop3/orm/app.py +895 -0
- hop3_server-0.4.0b1/src/hop3/orm/backup.py +54 -0
- hop3_server-0.4.0b1/src/hop3/orm/env.py +34 -0
- hop3_server-0.4.0b1/src/hop3/orm/repositories.py +16 -0
- hop3_server-0.4.0b1/src/hop3/orm/revoked_token.py +49 -0
- hop3_server-0.4.0b1/src/hop3/orm/security.py +115 -0
- hop3_server-0.4.0b1/src/hop3/orm/session.py +79 -0
- hop3_server-0.4.0b1/src/hop3/platform/__init__.py +1 -0
- hop3_server-0.4.0b1/src/hop3/platform/certificates.py +158 -0
- hop3_server-0.4.0b1/src/hop3/plugins/__init__.py +1 -0
- hop3_server-0.4.0b1/src/hop3/plugins/build/__init__.py +1 -0
- hop3_server-0.4.0b1/src/hop3/plugins/build/language_toolchains/__init__.py +15 -0
- hop3_server-0.4.0b1/src/hop3/plugins/build/language_toolchains/plugin.py +32 -0
- hop3_server-0.4.0b1/src/hop3/plugins/build/local_build/__init__.py +12 -0
- hop3_server-0.4.0b1/src/hop3/plugins/build/local_build/builder.py +116 -0
- hop3_server-0.4.0b1/src/hop3/plugins/build/local_build/plugin.py +25 -0
- hop3_server-0.4.0b1/src/hop3/plugins/deploy/__init__.py +1 -0
- hop3_server-0.4.0b1/src/hop3/plugins/deploy/static/__init__.py +6 -0
- hop3_server-0.4.0b1/src/hop3/plugins/deploy/static/deployer.py +194 -0
- hop3_server-0.4.0b1/src/hop3/plugins/deploy/static/plugin.py +25 -0
- hop3_server-0.4.0b1/src/hop3/plugins/deploy/uwsgi/__init__.py +1 -0
- hop3_server-0.4.0b1/src/hop3/plugins/deploy/uwsgi/deployer.py +216 -0
- hop3_server-0.4.0b1/src/hop3/plugins/deploy/uwsgi/plugin.py +25 -0
- hop3_server-0.4.0b1/src/hop3/plugins/docker/__init__.py +3 -0
- hop3_server-0.4.0b1/src/hop3/plugins/docker/builder.py +334 -0
- hop3_server-0.4.0b1/src/hop3/plugins/docker/deployer.py +821 -0
- hop3_server-0.4.0b1/src/hop3/plugins/docker/dockerfiles/Dockerfile-clojure +40 -0
- hop3_server-0.4.0b1/src/hop3/plugins/docker/dockerfiles/Dockerfile-go +35 -0
- hop3_server-0.4.0b1/src/hop3/plugins/docker/dockerfiles/Dockerfile-gradle +40 -0
- hop3_server-0.4.0b1/src/hop3/plugins/docker/dockerfiles/Dockerfile-maven +40 -0
- hop3_server-0.4.0b1/src/hop3/plugins/docker/dockerfiles/Dockerfile-node +43 -0
- hop3_server-0.4.0b1/src/hop3/plugins/docker/dockerfiles/Dockerfile-php +41 -0
- hop3_server-0.4.0b1/src/hop3/plugins/docker/dockerfiles/Dockerfile-python +58 -0
- hop3_server-0.4.0b1/src/hop3/plugins/docker/dockerfiles/Dockerfile-ruby +44 -0
- hop3_server-0.4.0b1/src/hop3/plugins/docker/dockerfiles/Dockerfile-rust +34 -0
- hop3_server-0.4.0b1/src/hop3/plugins/docker/dockerfiles/readme.md +7 -0
- hop3_server-0.4.0b1/src/hop3/plugins/docker/plugin.py +46 -0
- hop3_server-0.4.0b1/src/hop3/plugins/mysql/__init__.py +3 -0
- hop3_server-0.4.0b1/src/hop3/plugins/mysql/admin.py +197 -0
- hop3_server-0.4.0b1/src/hop3/plugins/mysql/cli.py +387 -0
- hop3_server-0.4.0b1/src/hop3/plugins/mysql/mysql.py +472 -0
- hop3_server-0.4.0b1/src/hop3/plugins/mysql/plugin.py +66 -0
- hop3_server-0.4.0b1/src/hop3/plugins/oses/README.md +326 -0
- hop3_server-0.4.0b1/src/hop3/plugins/oses/__init__.py +11 -0
- hop3_server-0.4.0b1/src/hop3/plugins/oses/arch.py +171 -0
- hop3_server-0.4.0b1/src/hop3/plugins/oses/base.py +168 -0
- hop3_server-0.4.0b1/src/hop3/plugins/oses/bsd.py +199 -0
- hop3_server-0.4.0b1/src/hop3/plugins/oses/debian_base.py +44 -0
- hop3_server-0.4.0b1/src/hop3/plugins/oses/debian_family.py +180 -0
- hop3_server-0.4.0b1/src/hop3/plugins/oses/macos.py +217 -0
- hop3_server-0.4.0b1/src/hop3/plugins/oses/redhat_base.py +43 -0
- hop3_server-0.4.0b1/src/hop3/plugins/oses/redhat_family.py +175 -0
- hop3_server-0.4.0b1/src/hop3/plugins/postgresql/__init__.py +1 -0
- hop3_server-0.4.0b1/src/hop3/plugins/postgresql/admin.py +196 -0
- hop3_server-0.4.0b1/src/hop3/plugins/postgresql/cli.py +447 -0
- hop3_server-0.4.0b1/src/hop3/plugins/postgresql/plugin.py +66 -0
- hop3_server-0.4.0b1/src/hop3/plugins/postgresql/postgres.py +449 -0
- hop3_server-0.4.0b1/src/hop3/plugins/proxy/__init__.py +1 -0
- hop3_server-0.4.0b1/src/hop3/plugins/proxy/caddy/__init__.py +9 -0
- hop3_server-0.4.0b1/src/hop3/plugins/proxy/caddy/_setup.py +365 -0
- hop3_server-0.4.0b1/src/hop3/plugins/proxy/caddy/_templates.py +92 -0
- hop3_server-0.4.0b1/src/hop3/plugins/proxy/caddy/plugin.py +26 -0
- hop3_server-0.4.0b1/src/hop3/plugins/proxy/nginx/__init__.py +10 -0
- hop3_server-0.4.0b1/src/hop3/plugins/proxy/nginx/_setup.py +429 -0
- hop3_server-0.4.0b1/src/hop3/plugins/proxy/nginx/_templates.py +155 -0
- hop3_server-0.4.0b1/src/hop3/plugins/proxy/nginx/plugin.py +26 -0
- hop3_server-0.4.0b1/src/hop3/plugins/proxy/traefik/__init__.py +9 -0
- hop3_server-0.4.0b1/src/hop3/plugins/proxy/traefik/_setup.py +354 -0
- hop3_server-0.4.0b1/src/hop3/plugins/proxy/traefik/_templates.py +137 -0
- hop3_server-0.4.0b1/src/hop3/plugins/proxy/traefik/plugin.py +26 -0
- hop3_server-0.4.0b1/src/hop3/plugins/redis/__init__.py +1 -0
- hop3_server-0.4.0b1/src/hop3/plugins/redis/cli.py +165 -0
- hop3_server-0.4.0b1/src/hop3/plugins/redis/factory.py +103 -0
- hop3_server-0.4.0b1/src/hop3/plugins/redis/plugin.py +66 -0
- hop3_server-0.4.0b1/src/hop3/plugins/redis/redis.py +398 -0
- hop3_server-0.4.0b1/src/hop3/project/__init__.py +3 -0
- hop3_server-0.4.0b1/src/hop3/project/config.py +221 -0
- hop3_server-0.4.0b1/src/hop3/project/hop3_config.py +307 -0
- hop3_server-0.4.0b1/src/hop3/project/procfile.py +132 -0
- hop3_server-0.4.0b1/src/hop3/run/__init__.py +4 -0
- hop3_server-0.4.0b1/src/hop3/run/spawn.py +323 -0
- hop3_server-0.4.0b1/src/hop3/run/uwsgi/__init__.py +7 -0
- hop3_server-0.4.0b1/src/hop3/run/uwsgi/settings.py +70 -0
- hop3_server-0.4.0b1/src/hop3/run/uwsgi/worker.py +450 -0
- hop3_server-0.4.0b1/src/hop3/server/__init__.py +1 -0
- hop3_server-0.4.0b1/src/hop3/server/asgi.py +174 -0
- hop3_server-0.4.0b1/src/hop3/server/cli/__init__.py +7 -0
- hop3_server-0.4.0b1/src/hop3/server/cli/_base.py +25 -0
- hop3_server-0.4.0b1/src/hop3/server/cli/admin.py +301 -0
- hop3_server-0.4.0b1/src/hop3/server/cli/cli.py +199 -0
- hop3_server-0.4.0b1/src/hop3/server/cli/help.py +158 -0
- hop3_server-0.4.0b1/src/hop3/server/cli/local.py +234 -0
- hop3_server-0.4.0b1/src/hop3/server/cli/plugins.py +373 -0
- hop3_server-0.4.0b1/src/hop3/server/cli/serve.py +45 -0
- hop3_server-0.4.0b1/src/hop3/server/cli/setup.py +294 -0
- hop3_server-0.4.0b1/src/hop3/server/controllers/__init__.py +21 -0
- hop3_server-0.4.0b1/src/hop3/server/controllers/auth.py +147 -0
- hop3_server-0.4.0b1/src/hop3/server/controllers/dashboard.py +979 -0
- hop3_server-0.4.0b1/src/hop3/server/controllers/marketplace.py +335 -0
- hop3_server-0.4.0b1/src/hop3/server/controllers/root.py +47 -0
- hop3_server-0.4.0b1/src/hop3/server/controllers/rpc.py +415 -0
- hop3_server-0.4.0b1/src/hop3/server/guards.py +70 -0
- hop3_server-0.4.0b1/src/hop3/server/lib/__init__.py +1 -0
- hop3_server-0.4.0b1/src/hop3/server/lib/database.py +30 -0
- hop3_server-0.4.0b1/src/hop3/server/lib/decorators.py +10 -0
- hop3_server-0.4.0b1/src/hop3/server/lib/registry.py +87 -0
- hop3_server-0.4.0b1/src/hop3/server/lib/scanner.py +37 -0
- hop3_server-0.4.0b1/src/hop3/server/lib/types.py +6 -0
- hop3_server-0.4.0b1/src/hop3/server/marketplace/__init__.py +18 -0
- hop3_server-0.4.0b1/src/hop3/server/marketplace/loader.py +109 -0
- hop3_server-0.4.0b1/src/hop3/server/marketplace/models.py +138 -0
- hop3_server-0.4.0b1/src/hop3/server/marketplace/service.py +165 -0
- hop3_server-0.4.0b1/src/hop3/server/marketplace/taxonomy.py +160 -0
- hop3_server-0.4.0b1/src/hop3/server/middleware/__init__.py +5 -0
- hop3_server-0.4.0b1/src/hop3/server/security/__init__.py +9 -0
- hop3_server-0.4.0b1/src/hop3/server/security/tokens.py +212 -0
- hop3_server-0.4.0b1/src/hop3/server/state_sync.py +225 -0
- hop3_server-0.4.0b1/src/hop3/server/static/favicon.png +0 -0
- hop3_server-0.4.0b1/src/hop3/server/static/readme.md +1 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/auth/login.html +87 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/auth/profile.html +86 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/base.html +176 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/dashboard/_app_status.html +88 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/dashboard/addon_detail.html +247 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/dashboard/addons.html +127 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/dashboard/app_create.html +145 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/dashboard/app_create_pending.html +62 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/dashboard/app_detail.html +366 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/dashboard/backup_info.html +278 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/dashboard/backups.html +114 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/dashboard/env_vars.html +288 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/dashboard/index.html +181 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/dashboard/logs.html +235 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/dashboard/marketplace/_app_card.html +49 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/dashboard/marketplace/category.html +102 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/dashboard/marketplace/detail.html +245 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/dashboard/marketplace/index.html +131 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/dashboard/marketplace/list.html +161 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/term-ws.j2 +155 -0
- hop3_server-0.4.0b1/src/hop3/server/templates/term.j2 +49 -0
- hop3_server-0.4.0b1/src/hop3/toolchains/__init__.py +38 -0
- hop3_server-0.4.0b1/src/hop3/toolchains/_base.py +158 -0
- hop3_server-0.4.0b1/src/hop3/toolchains/clojure.py +112 -0
- hop3_server-0.4.0b1/src/hop3/toolchains/dotnet.py +54 -0
- hop3_server-0.4.0b1/src/hop3/toolchains/elixir.py +69 -0
- hop3_server-0.4.0b1/src/hop3/toolchains/go.py +75 -0
- hop3_server-0.4.0b1/src/hop3/toolchains/java.py +77 -0
- hop3_server-0.4.0b1/src/hop3/toolchains/node.py +148 -0
- hop3_server-0.4.0b1/src/hop3/toolchains/php.py +75 -0
- hop3_server-0.4.0b1/src/hop3/toolchains/python.py +146 -0
- hop3_server-0.4.0b1/src/hop3/toolchains/ruby.py +97 -0
- hop3_server-0.4.0b1/src/hop3/toolchains/rust.py +97 -0
- hop3_server-0.4.0b1/src/hop3/toolchains/static.py +86 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: hop3-server
|
|
3
|
+
Version: 0.4.0b1
|
|
4
|
+
Summary: Simple PaaS - Deploy and manage web applications on a single server
|
|
5
|
+
Author: Stefane Fermigier
|
|
6
|
+
Author-email: Stefane Fermigier <sf@abilian.com>
|
|
7
|
+
Requires-Dist: litestar[standard]>=2.18.0
|
|
8
|
+
Requires-Dist: attrs>=24.2
|
|
9
|
+
Requires-Dist: jinja2
|
|
10
|
+
Requires-Dist: itsdangerous>=2.0.0
|
|
11
|
+
Requires-Dist: pluggy~=1.4
|
|
12
|
+
Requires-Dist: dishka>=1.3.0
|
|
13
|
+
Requires-Dist: sqlalchemy~=2.0
|
|
14
|
+
Requires-Dist: advanced-alchemy>=0.21
|
|
15
|
+
Requires-Dist: alembic~=1.13
|
|
16
|
+
Requires-Dist: termcolor>=2.5.0
|
|
17
|
+
Requires-Dist: markdown>=3.5
|
|
18
|
+
Requires-Dist: cyclonedx-bom>=5.1.1
|
|
19
|
+
Requires-Dist: toml>=0.10.2
|
|
20
|
+
Requires-Dist: devtools
|
|
21
|
+
Requires-Dist: pyjwt>=2.8.0
|
|
22
|
+
Requires-Dist: bcrypt>=4.0.0
|
|
23
|
+
Requires-Dist: cryptography>=42.0.0
|
|
24
|
+
Requires-Dist: granian[reload]>=2.2.0
|
|
25
|
+
Requires-Dist: psycopg2-binary>=2.9.10
|
|
26
|
+
Requires-Dist: mysql-connector-python>=9.0.0
|
|
27
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
28
|
+
Requires-Dist: python-multipart>=0.0.20
|
|
29
|
+
Requires-Dist: anyio
|
|
30
|
+
Requires-Dist: sniffio
|
|
31
|
+
Requires-Dist: uwsgi>=2.0.31
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# hop3-server
|
|
35
|
+
|
|
36
|
+
Core server for the Hop3 Platform-as-a-Service.
|
|
37
|
+
|
|
38
|
+
## Overview
|
|
39
|
+
|
|
40
|
+
hop3-server is the central orchestrator that handles application deployments, process management, reverse proxy configuration, and addon services. It provides a JSON-RPC API for communication with hop3-cli and hop3-tui.
|
|
41
|
+
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
- **Git-push deployments** - Deploy applications via `git push`
|
|
45
|
+
- **Automatic build system** - Detects language (Python, Node, Ruby, Go, Rust, etc.) and builds automatically
|
|
46
|
+
- **Process management** - Manages app processes based on Procfile via uWSGI
|
|
47
|
+
- **Reverse proxy** - Nginx/Caddy/Traefik with automatic SSL certificates
|
|
48
|
+
- **Addon services** - PostgreSQL, MySQL, Redis management
|
|
49
|
+
- **Plugin architecture** - Extensible via pluggy-based plugins
|
|
50
|
+
- **JSON-RPC API** - For CLI and TUI communication
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
### For development
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# From workspace root
|
|
58
|
+
cd packages/hop3-server
|
|
59
|
+
uv pip install -e ".[dev]"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Production installation
|
|
63
|
+
|
|
64
|
+
Use hop3-installer:
|
|
65
|
+
```bash
|
|
66
|
+
curl -LsSf https://hop3.cloud/install-server.py | sudo python3 -
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Quick Start
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Run the server
|
|
73
|
+
hop3-server serve
|
|
74
|
+
|
|
75
|
+
# Run with specific host/port
|
|
76
|
+
hop3-server serve --host 0.0.0.0 --port 8000
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Architecture
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
hop3-server/
|
|
83
|
+
├── src/hop3/
|
|
84
|
+
│ ├── server/ # Litestar ASGI application
|
|
85
|
+
│ │ ├── asgi.py # App factory
|
|
86
|
+
│ │ ├── controllers/ # API endpoints
|
|
87
|
+
│ │ └── security/ # Authentication
|
|
88
|
+
│ ├── commands/ # RPC command handlers
|
|
89
|
+
│ ├── deployers/ # Deployment orchestration
|
|
90
|
+
│ ├── orm/ # SQLAlchemy models (App, EnvVar)
|
|
91
|
+
│ ├── plugins/ # Plugin system
|
|
92
|
+
│ │ ├── build/ # Builders, language toolchains
|
|
93
|
+
│ │ ├── deploy/ # Deployers (uWSGI, static)
|
|
94
|
+
│ │ ├── proxy/ # Nginx, Caddy, Traefik
|
|
95
|
+
│ │ ├── oses/ # OS implementations
|
|
96
|
+
│ │ ├── postgresql/ # PostgreSQL addon
|
|
97
|
+
│ │ ├── mysql/ # MySQL addon
|
|
98
|
+
│ │ └── redis/ # Redis addon
|
|
99
|
+
│ ├── core/ # Core abstractions
|
|
100
|
+
│ │ ├── protocols.py # Plugin protocols
|
|
101
|
+
│ │ ├── hookspecs.py # Hook specifications
|
|
102
|
+
│ │ └── plugins.py # Plugin manager
|
|
103
|
+
│ ├── toolchains/ # Language toolchains
|
|
104
|
+
│ ├── run/ # Runtime process management
|
|
105
|
+
│ └── project/ # Procfile parsing
|
|
106
|
+
└── tests/
|
|
107
|
+
├── a_unit/ # Unit tests
|
|
108
|
+
├── b_integration/ # Integration tests
|
|
109
|
+
├── c_system/ # System tests
|
|
110
|
+
└── d_e2e/ # End-to-end tests
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Deployment Flow
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
git push → Git hook → Deployer → Builder → Language Toolchain → uWSGI config → Nginx config
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Filesystem Layout
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
/home/hop3/
|
|
123
|
+
├── apps/<app_name>/
|
|
124
|
+
│ ├── git/ # Bare git repository
|
|
125
|
+
│ ├── src/ # Checked-out source code
|
|
126
|
+
│ ├── data/ # Persistent data
|
|
127
|
+
│ ├── log/ # Log files
|
|
128
|
+
│ └── venv/ # Python virtualenv (if applicable)
|
|
129
|
+
├── nginx/ # Nginx configs and certs
|
|
130
|
+
├── uwsgi-available/ # uWSGI configs
|
|
131
|
+
├── uwsgi-enabled/ # Active uWSGI configs (symlinks)
|
|
132
|
+
└── hop3.db # SQLite database
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Configuration
|
|
136
|
+
|
|
137
|
+
Server configuration via environment variables or `/etc/hop3/config.toml`:
|
|
138
|
+
|
|
139
|
+
| Variable | Description | Default |
|
|
140
|
+
|----------|-------------|---------|
|
|
141
|
+
| `HOP3_HOME` | Home directory | `/home/hop3` |
|
|
142
|
+
| `HOP3_DATABASE_URL` | Database URL | `sqlite:///hop3.db` |
|
|
143
|
+
| `HOP3_SECRET_KEY` | JWT signing key | (required) |
|
|
144
|
+
|
|
145
|
+
## Development
|
|
146
|
+
|
|
147
|
+
### Running tests
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Unit tests
|
|
151
|
+
uv run pytest tests/a_unit/ -v
|
|
152
|
+
|
|
153
|
+
# Integration tests
|
|
154
|
+
uv run pytest -n 4 tests/b_integration/ -v
|
|
155
|
+
|
|
156
|
+
# System tests (requires Docker)
|
|
157
|
+
uv run pytest tests/c_system/ -v
|
|
158
|
+
|
|
159
|
+
# E2E tests (slow)
|
|
160
|
+
uv run pytest tests/d_e2e/ -v
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Code quality
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
uv run ruff check src/
|
|
167
|
+
uv run ruff format src/
|
|
168
|
+
uv run pyright src/
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Plugin Development
|
|
172
|
+
|
|
173
|
+
See [Plugin Development Guide](../../docs/src/dev/plugin-development.md) for creating:
|
|
174
|
+
- Language toolchains (new language support)
|
|
175
|
+
- Addons (new backing services)
|
|
176
|
+
- Deployers (new runtime strategies)
|
|
177
|
+
- Proxies (new reverse proxy support)
|
|
178
|
+
|
|
179
|
+
## Documentation
|
|
180
|
+
|
|
181
|
+
- **User Guide**: [Main documentation](../../docs/src/guide.md)
|
|
182
|
+
- **System Architecture**: [Architecture overview](../../docs/src/dev/architecture.md)
|
|
183
|
+
- **Plugin Development**: [Plugin guide](../../docs/src/dev/plugin-development.md)
|
|
184
|
+
- **Testing Strategy**: [Testing guide](../../docs/src/dev/testing-strategy.md)
|
|
185
|
+
- **Package Internals**: [Deep-dive documentation](./docs/internals.md)
|
|
186
|
+
|
|
187
|
+
## Related Packages
|
|
188
|
+
|
|
189
|
+
- [hop3-cli](../hop3-cli/) - CLI client for this server
|
|
190
|
+
- [hop3-tui](../hop3-tui/) - TUI client for this server
|
|
191
|
+
- [hop3-installer](../hop3-installer/) - Installation tools
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
Apache-2.0 - Copyright (c) 2024-2025, Abilian SAS
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# hop3-server
|
|
2
|
+
|
|
3
|
+
Core server for the Hop3 Platform-as-a-Service.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
hop3-server is the central orchestrator that handles application deployments, process management, reverse proxy configuration, and addon services. It provides a JSON-RPC API for communication with hop3-cli and hop3-tui.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Git-push deployments** - Deploy applications via `git push`
|
|
12
|
+
- **Automatic build system** - Detects language (Python, Node, Ruby, Go, Rust, etc.) and builds automatically
|
|
13
|
+
- **Process management** - Manages app processes based on Procfile via uWSGI
|
|
14
|
+
- **Reverse proxy** - Nginx/Caddy/Traefik with automatic SSL certificates
|
|
15
|
+
- **Addon services** - PostgreSQL, MySQL, Redis management
|
|
16
|
+
- **Plugin architecture** - Extensible via pluggy-based plugins
|
|
17
|
+
- **JSON-RPC API** - For CLI and TUI communication
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
### For development
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# From workspace root
|
|
25
|
+
cd packages/hop3-server
|
|
26
|
+
uv pip install -e ".[dev]"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Production installation
|
|
30
|
+
|
|
31
|
+
Use hop3-installer:
|
|
32
|
+
```bash
|
|
33
|
+
curl -LsSf https://hop3.cloud/install-server.py | sudo python3 -
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Run the server
|
|
40
|
+
hop3-server serve
|
|
41
|
+
|
|
42
|
+
# Run with specific host/port
|
|
43
|
+
hop3-server serve --host 0.0.0.0 --port 8000
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Architecture
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
hop3-server/
|
|
50
|
+
├── src/hop3/
|
|
51
|
+
│ ├── server/ # Litestar ASGI application
|
|
52
|
+
│ │ ├── asgi.py # App factory
|
|
53
|
+
│ │ ├── controllers/ # API endpoints
|
|
54
|
+
│ │ └── security/ # Authentication
|
|
55
|
+
│ ├── commands/ # RPC command handlers
|
|
56
|
+
│ ├── deployers/ # Deployment orchestration
|
|
57
|
+
│ ├── orm/ # SQLAlchemy models (App, EnvVar)
|
|
58
|
+
│ ├── plugins/ # Plugin system
|
|
59
|
+
│ │ ├── build/ # Builders, language toolchains
|
|
60
|
+
│ │ ├── deploy/ # Deployers (uWSGI, static)
|
|
61
|
+
│ │ ├── proxy/ # Nginx, Caddy, Traefik
|
|
62
|
+
│ │ ├── oses/ # OS implementations
|
|
63
|
+
│ │ ├── postgresql/ # PostgreSQL addon
|
|
64
|
+
│ │ ├── mysql/ # MySQL addon
|
|
65
|
+
│ │ └── redis/ # Redis addon
|
|
66
|
+
│ ├── core/ # Core abstractions
|
|
67
|
+
│ │ ├── protocols.py # Plugin protocols
|
|
68
|
+
│ │ ├── hookspecs.py # Hook specifications
|
|
69
|
+
│ │ └── plugins.py # Plugin manager
|
|
70
|
+
│ ├── toolchains/ # Language toolchains
|
|
71
|
+
│ ├── run/ # Runtime process management
|
|
72
|
+
│ └── project/ # Procfile parsing
|
|
73
|
+
└── tests/
|
|
74
|
+
├── a_unit/ # Unit tests
|
|
75
|
+
├── b_integration/ # Integration tests
|
|
76
|
+
├── c_system/ # System tests
|
|
77
|
+
└── d_e2e/ # End-to-end tests
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Deployment Flow
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
git push → Git hook → Deployer → Builder → Language Toolchain → uWSGI config → Nginx config
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Filesystem Layout
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
/home/hop3/
|
|
90
|
+
├── apps/<app_name>/
|
|
91
|
+
│ ├── git/ # Bare git repository
|
|
92
|
+
│ ├── src/ # Checked-out source code
|
|
93
|
+
│ ├── data/ # Persistent data
|
|
94
|
+
│ ├── log/ # Log files
|
|
95
|
+
│ └── venv/ # Python virtualenv (if applicable)
|
|
96
|
+
├── nginx/ # Nginx configs and certs
|
|
97
|
+
├── uwsgi-available/ # uWSGI configs
|
|
98
|
+
├── uwsgi-enabled/ # Active uWSGI configs (symlinks)
|
|
99
|
+
└── hop3.db # SQLite database
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Configuration
|
|
103
|
+
|
|
104
|
+
Server configuration via environment variables or `/etc/hop3/config.toml`:
|
|
105
|
+
|
|
106
|
+
| Variable | Description | Default |
|
|
107
|
+
|----------|-------------|---------|
|
|
108
|
+
| `HOP3_HOME` | Home directory | `/home/hop3` |
|
|
109
|
+
| `HOP3_DATABASE_URL` | Database URL | `sqlite:///hop3.db` |
|
|
110
|
+
| `HOP3_SECRET_KEY` | JWT signing key | (required) |
|
|
111
|
+
|
|
112
|
+
## Development
|
|
113
|
+
|
|
114
|
+
### Running tests
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Unit tests
|
|
118
|
+
uv run pytest tests/a_unit/ -v
|
|
119
|
+
|
|
120
|
+
# Integration tests
|
|
121
|
+
uv run pytest -n 4 tests/b_integration/ -v
|
|
122
|
+
|
|
123
|
+
# System tests (requires Docker)
|
|
124
|
+
uv run pytest tests/c_system/ -v
|
|
125
|
+
|
|
126
|
+
# E2E tests (slow)
|
|
127
|
+
uv run pytest tests/d_e2e/ -v
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Code quality
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
uv run ruff check src/
|
|
134
|
+
uv run ruff format src/
|
|
135
|
+
uv run pyright src/
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Plugin Development
|
|
139
|
+
|
|
140
|
+
See [Plugin Development Guide](../../docs/src/dev/plugin-development.md) for creating:
|
|
141
|
+
- Language toolchains (new language support)
|
|
142
|
+
- Addons (new backing services)
|
|
143
|
+
- Deployers (new runtime strategies)
|
|
144
|
+
- Proxies (new reverse proxy support)
|
|
145
|
+
|
|
146
|
+
## Documentation
|
|
147
|
+
|
|
148
|
+
- **User Guide**: [Main documentation](../../docs/src/guide.md)
|
|
149
|
+
- **System Architecture**: [Architecture overview](../../docs/src/dev/architecture.md)
|
|
150
|
+
- **Plugin Development**: [Plugin guide](../../docs/src/dev/plugin-development.md)
|
|
151
|
+
- **Testing Strategy**: [Testing guide](../../docs/src/dev/testing-strategy.md)
|
|
152
|
+
- **Package Internals**: [Deep-dive documentation](./docs/internals.md)
|
|
153
|
+
|
|
154
|
+
## Related Packages
|
|
155
|
+
|
|
156
|
+
- [hop3-cli](../hop3-cli/) - CLI client for this server
|
|
157
|
+
- [hop3-tui](../hop3-tui/) - TUI client for this server
|
|
158
|
+
- [hop3-installer](../hop3-installer/) - Installation tools
|
|
159
|
+
|
|
160
|
+
## License
|
|
161
|
+
|
|
162
|
+
Apache-2.0 - Copyright (c) 2024-2025, Abilian SAS
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "hop3-server"
|
|
3
|
+
version = "0.4.0.beta1"
|
|
4
|
+
description = "Simple PaaS - Deploy and manage web applications on a single server"
|
|
5
|
+
authors = [
|
|
6
|
+
{ name = "Stefane Fermigier", email = "sf@abilian.com" },
|
|
7
|
+
]
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
|
|
10
|
+
dependencies = [
|
|
11
|
+
# Web / app server
|
|
12
|
+
"litestar[standard]>=2.18.0",
|
|
13
|
+
"attrs >= 24.2",
|
|
14
|
+
"jinja2",
|
|
15
|
+
"itsdangerous>=2.0.0",
|
|
16
|
+
# Plugins and DI
|
|
17
|
+
"pluggy ~= 1.4",
|
|
18
|
+
"dishka >= 1.3.0",
|
|
19
|
+
# Database
|
|
20
|
+
"sqlalchemy ~= 2.0",
|
|
21
|
+
"advanced-alchemy >= 0.21",
|
|
22
|
+
"alembic ~= 1.13",
|
|
23
|
+
# Misc
|
|
24
|
+
"termcolor >= 2.5.0",
|
|
25
|
+
"markdown>=3.5",
|
|
26
|
+
# SBOM
|
|
27
|
+
"cyclonedx-bom >= 5.1.1",
|
|
28
|
+
"toml >= 0.10.2",
|
|
29
|
+
# Utils
|
|
30
|
+
"devtools",
|
|
31
|
+
# Security
|
|
32
|
+
"pyjwt>=2.8.0",
|
|
33
|
+
"bcrypt>=4.0.0",
|
|
34
|
+
"cryptography>=42.0.0",
|
|
35
|
+
# ASGI server
|
|
36
|
+
"granian[reload]>=2.2.0",
|
|
37
|
+
# PostgreSQL
|
|
38
|
+
"psycopg2-binary>=2.9.10",
|
|
39
|
+
# MySQL
|
|
40
|
+
"mysql-connector-python>=9.0.0",
|
|
41
|
+
# Config
|
|
42
|
+
"pyyaml>=6.0.3",
|
|
43
|
+
"python-multipart>=0.0.20",
|
|
44
|
+
# Transitive dependencies
|
|
45
|
+
"anyio",
|
|
46
|
+
# Needed for some reason
|
|
47
|
+
"sniffio",
|
|
48
|
+
"uwsgi>=2.0.31",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
[dependency-groups]
|
|
52
|
+
dev = [
|
|
53
|
+
"typing-extensions>=4.12.2",
|
|
54
|
+
"httpx>=0.27.0",
|
|
55
|
+
"pytest-asyncio>=0.23.0",
|
|
56
|
+
"hop3-testing",
|
|
57
|
+
"types-pyyaml>=6.0.12.20250915",
|
|
58
|
+
"types-markdown>=3.10.0.20251106",
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
[project.scripts]
|
|
62
|
+
hop3-server = "hop3.server.cli:main"
|
|
63
|
+
|
|
64
|
+
# ----------------------------------------
|
|
65
|
+
|
|
66
|
+
[build-system]
|
|
67
|
+
requires = ["uv-build>=0.8.4,<0.9.0"]
|
|
68
|
+
build-backend = "uv_build"
|
|
69
|
+
|
|
70
|
+
[tool.uv.build-backend]
|
|
71
|
+
module-name = "hop3"
|
|
72
|
+
module-root = "src"
|
|
73
|
+
|
|
74
|
+
#[tool.uv.sources]
|
|
75
|
+
#hop3-testing = { path = "../hop3-testing", editable = true }
|
|
76
|
+
|
|
77
|
+
# ----------------------------------------
|
|
78
|
+
|
|
79
|
+
[tool.pyright]
|
|
80
|
+
exclude = [
|
|
81
|
+
"src/hop3/util/templating.py",
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
# -----------------------------------------------------------------------------
|
|
85
|
+
|
|
86
|
+
# X imported but missing from the dependency definitions
|
|
87
|
+
[tool.deptry.per_rule_ignores]
|
|
88
|
+
DEP001 = [
|
|
89
|
+
"tomli",
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
# X defined as a dependency but not used in the codebase
|
|
93
|
+
DEP002 = [
|
|
94
|
+
"cyclonedx-bom",
|
|
95
|
+
"jinja2",
|
|
96
|
+
"itsdangerous",
|
|
97
|
+
"python-multipart",
|
|
98
|
+
"sniffio",
|
|
99
|
+
]
|
|
100
|
+
|
|
101
|
+
#DEP003 = [
|
|
102
|
+
# "snoop",
|
|
103
|
+
#]
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Copyright (c) 2023-2025, Abilian SAS
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Generic single-database configuration.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Copyright (c) 2025, Abilian SAS
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from logging.config import fileConfig
|
|
5
|
+
|
|
6
|
+
from alembic import context
|
|
7
|
+
from sqlalchemy import engine_from_config, pool
|
|
8
|
+
|
|
9
|
+
# Import Hop3's configuration and models
|
|
10
|
+
from hop3 import config as hop3_config
|
|
11
|
+
from hop3.orm.app import App
|
|
12
|
+
|
|
13
|
+
# this is the Alembic Config object, which provides
|
|
14
|
+
# access to the values within the .ini file in use.
|
|
15
|
+
config = context.config
|
|
16
|
+
|
|
17
|
+
# Get database URL from Hop3 config, falling back to alembic.ini
|
|
18
|
+
database_url = config.get_main_option("sqlalchemy.url")
|
|
19
|
+
if not database_url or database_url == "driver://user:pass@localhost/dbname":
|
|
20
|
+
# Use Hop3's default database path
|
|
21
|
+
database_url = f"sqlite:///{hop3_config.HOP3_ROOT}/hop3.db"
|
|
22
|
+
|
|
23
|
+
# Override the sqlalchemy.url in the config
|
|
24
|
+
config.set_main_option("sqlalchemy.url", database_url)
|
|
25
|
+
|
|
26
|
+
# Interpret the config file for Python logging.
|
|
27
|
+
# This line sets up loggers basically.
|
|
28
|
+
if config.config_file_name is not None:
|
|
29
|
+
fileConfig(config.config_file_name)
|
|
30
|
+
|
|
31
|
+
# add your model's MetaData object here
|
|
32
|
+
# for 'autogenerate' support
|
|
33
|
+
target_metadata = App.metadata
|
|
34
|
+
|
|
35
|
+
# other values from the config, defined by the needs of env.py,
|
|
36
|
+
# can be acquired:
|
|
37
|
+
# my_important_option = config.get_main_option("my_important_option")
|
|
38
|
+
# ... etc.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def run_migrations_offline() -> None:
|
|
42
|
+
"""Run migrations in 'offline' mode.
|
|
43
|
+
|
|
44
|
+
This configures the context with just a URL
|
|
45
|
+
and not an Engine, though an Engine is acceptable
|
|
46
|
+
here as well. By skipping the Engine creation
|
|
47
|
+
we don't even need a DBAPI to be available.
|
|
48
|
+
|
|
49
|
+
Calls to context.execute() here emit the given string to the
|
|
50
|
+
script output.
|
|
51
|
+
|
|
52
|
+
"""
|
|
53
|
+
url = config.get_main_option("sqlalchemy.url")
|
|
54
|
+
context.configure(
|
|
55
|
+
url=url,
|
|
56
|
+
target_metadata=target_metadata,
|
|
57
|
+
literal_binds=True,
|
|
58
|
+
dialect_opts={"paramstyle": "named"},
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
with context.begin_transaction():
|
|
62
|
+
context.run_migrations()
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def run_migrations_online() -> None:
|
|
66
|
+
"""Run migrations in 'online' mode.
|
|
67
|
+
|
|
68
|
+
In this scenario we need to create an Engine
|
|
69
|
+
and associate a connection with the context.
|
|
70
|
+
|
|
71
|
+
"""
|
|
72
|
+
# Check if we're being called programmatically with a connection
|
|
73
|
+
connectable = config.attributes.get("connection", None)
|
|
74
|
+
|
|
75
|
+
if connectable is None:
|
|
76
|
+
# CLI mode: create engine from config
|
|
77
|
+
connectable = engine_from_config(
|
|
78
|
+
config.get_section(config.config_ini_section, {}),
|
|
79
|
+
prefix="sqlalchemy.",
|
|
80
|
+
poolclass=pool.NullPool,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
with connectable.connect() as connection:
|
|
84
|
+
context.configure(connection=connection, target_metadata=target_metadata)
|
|
85
|
+
|
|
86
|
+
with context.begin_transaction():
|
|
87
|
+
context.run_migrations()
|
|
88
|
+
else:
|
|
89
|
+
# Programmatic mode: use provided connection
|
|
90
|
+
context.configure(connection=connectable, target_metadata=target_metadata)
|
|
91
|
+
|
|
92
|
+
with context.begin_transaction():
|
|
93
|
+
context.run_migrations()
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
if context.is_offline_mode():
|
|
97
|
+
run_migrations_offline()
|
|
98
|
+
else:
|
|
99
|
+
run_migrations_online()
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""${message}
|
|
2
|
+
|
|
3
|
+
Revision ID: ${up_revision}
|
|
4
|
+
Revises: ${down_revision | comma,n}
|
|
5
|
+
Create Date: ${create_date}
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
from typing import Sequence, Union
|
|
9
|
+
|
|
10
|
+
from alembic import op
|
|
11
|
+
import sqlalchemy as sa
|
|
12
|
+
${imports if imports else ""}
|
|
13
|
+
|
|
14
|
+
# revision identifiers, used by Alembic.
|
|
15
|
+
revision: str = ${repr(up_revision)}
|
|
16
|
+
down_revision: Union[str, Sequence[str], None] = ${repr(down_revision)}
|
|
17
|
+
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
|
18
|
+
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def upgrade() -> None:
|
|
22
|
+
"""Upgrade schema."""
|
|
23
|
+
${upgrades if upgrades else "pass"}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def downgrade() -> None:
|
|
27
|
+
"""Downgrade schema."""
|
|
28
|
+
${downgrades if downgrades else "pass"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Copyright (c) 2025, Abilian SAS
|
|
2
|
+
"""add_app_state_machine_and_error_message
|
|
3
|
+
|
|
4
|
+
Revision ID: 0d21c362f66d
|
|
5
|
+
Revises: d20dd80dafca
|
|
6
|
+
Create Date: 2025-11-24 15:20:32.212565
|
|
7
|
+
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from collections.abc import Sequence
|
|
13
|
+
|
|
14
|
+
import sqlalchemy as sa
|
|
15
|
+
from alembic import op
|
|
16
|
+
|
|
17
|
+
# revision identifiers, used by Alembic.
|
|
18
|
+
revision: str = "0d21c362f66d"
|
|
19
|
+
down_revision: str | Sequence[str] | None = "d20dd80dafca"
|
|
20
|
+
branch_labels: str | Sequence[str] | None = None
|
|
21
|
+
depends_on: str | Sequence[str] | None = None
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def upgrade() -> None:
|
|
25
|
+
"""Upgrade schema to add error_message column and update state enum values.
|
|
26
|
+
|
|
27
|
+
Changes:
|
|
28
|
+
- Add error_message column to app table
|
|
29
|
+
- Update run_state enum values (remove PAUSED, add STARTING, STOPPING, FAILED)
|
|
30
|
+
- STOPPED=1, STARTING=2, RUNNING=3, STOPPING=4, FAILED=5
|
|
31
|
+
"""
|
|
32
|
+
# Add error_message column
|
|
33
|
+
op.add_column(
|
|
34
|
+
"app",
|
|
35
|
+
sa.Column(
|
|
36
|
+
"error_message", sa.String(length=1024), server_default="", nullable=False
|
|
37
|
+
),
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
# Note: SQLite doesn't support ALTER TYPE for enums
|
|
41
|
+
# The new state values will work because we're using integers (1-5)
|
|
42
|
+
# Old states: RUNNING=1, STOPPED=2, PAUSED=3
|
|
43
|
+
# New states: STOPPED=1, STARTING=2, RUNNING=3, STOPPING=4, FAILED=5
|
|
44
|
+
# We need to update existing state values:
|
|
45
|
+
# - RUNNING (1) stays as 1, but becomes STOPPED (will be handled by application logic)
|
|
46
|
+
# - STOPPED (2) stays as 2, which becomes STARTING (will fix below)
|
|
47
|
+
# - PAUSED (3) becomes RUNNING (3)
|
|
48
|
+
|
|
49
|
+
# Actually, let's keep it simple for this migration:
|
|
50
|
+
# Old RUNNING (1) -> New RUNNING (3) - needs update
|
|
51
|
+
# Old STOPPED (2) -> New STOPPED (1) - needs update
|
|
52
|
+
# Old PAUSED (3) -> New STOPPED (1) - needs update
|
|
53
|
+
|
|
54
|
+
# For safety, we'll transition all apps to STOPPED state (1)
|
|
55
|
+
op.execute("UPDATE app SET run_state = 1")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def downgrade() -> None:
|
|
59
|
+
"""Downgrade schema."""
|
|
60
|
+
# Remove error_message column
|
|
61
|
+
op.drop_column("app", "error_message")
|
|
62
|
+
|
|
63
|
+
# Note: State values will need manual intervention if downgrading
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Copyright (c) 2025, Abilian SAS
|
|
2
|
+
"""add runtime field to app model
|
|
3
|
+
|
|
4
|
+
Revision ID: 961bfd2ecce5
|
|
5
|
+
Revises: 0d21c362f66d
|
|
6
|
+
Create Date: 2025-11-24 22:19:14.012460
|
|
7
|
+
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from collections.abc import Sequence
|
|
13
|
+
|
|
14
|
+
import sqlalchemy as sa
|
|
15
|
+
from alembic import op
|
|
16
|
+
|
|
17
|
+
# revision identifiers, used by Alembic.
|
|
18
|
+
revision: str = "961bfd2ecce5"
|
|
19
|
+
down_revision: str | Sequence[str] | None = "0d21c362f66d"
|
|
20
|
+
branch_labels: str | Sequence[str] | None = None
|
|
21
|
+
depends_on: str | Sequence[str] | None = None
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def upgrade() -> None:
|
|
25
|
+
"""Upgrade schema to add runtime field."""
|
|
26
|
+
# Add runtime column with default value 'uwsgi' for existing apps
|
|
27
|
+
op.add_column(
|
|
28
|
+
"app",
|
|
29
|
+
sa.Column(
|
|
30
|
+
"runtime", sa.String(length=64), server_default="uwsgi", nullable=False
|
|
31
|
+
),
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def downgrade() -> None:
|
|
36
|
+
"""Downgrade schema to remove runtime field."""
|
|
37
|
+
op.drop_column("app", "runtime")
|