Compare commits
80 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a3eefbe92c | |||
| 41679427c6 | |||
| c420a30341 | |||
| fe109f0953 | |||
| 012dce63b1 | |||
| 54780482c7 | |||
| 7ab0fb3c1f | |||
| 713fda2a86 | |||
| ec32c19300 | |||
| 7d1d91157c | |||
| b69c96c240 | |||
| 9ee8851d03 | |||
| 7f6031f31a | |||
| 6f1b8469e0 | |||
| cd06c74cc3 | |||
| d3acc720ca | |||
| 1b6de75097 | |||
| 497f8f59a7 | |||
| 0c7d65e4ad | |||
| 3f2cd074ce | |||
| 59ed7233bd | |||
| 01e3ba16c4 | |||
| f5c1d5fcda | |||
| 45b0971f2f | |||
| 178f440d7e | |||
| 7fff15a90c | |||
| 69e23f667e | |||
| a2bf4df7c2 | |||
| 9e0a0b5a89 | |||
| 3a227bd838 | |||
| f5a7fccfc2 | |||
| a30d2029a5 | |||
| 88727dd47d | |||
| 9a5ed2220e | |||
| decd39e7c4 | |||
| ad2e228208 | |||
| cf06019d79 | |||
| cf44b0047d | |||
| 260b5364e6 | |||
| 51c1962042 | |||
| d3b78054ad | |||
| d2ae35f0ce | |||
| a605477663 | |||
| ba98086548 | |||
| 0b3c22556b | |||
| 069e6e6c8f | |||
| 10598520d8 | |||
| 075b7946b1 | |||
| f47fca3304 | |||
| 575e010a6b | |||
| 60a5dc4663 | |||
| 36d80b1e27 | |||
| 465cf0ee72 | |||
| bd5cd5c0cb | |||
| b622565e34 | |||
| 56376121ab | |||
| e3359d1235 | |||
| f1eeec6922 | |||
| 69362bb529 | |||
| 857fcc50ba | |||
| 5d0df006eb | |||
| e6256502ce | |||
| d5dc141171 | |||
| 2538f5ae2c | |||
| 4613193dcc | |||
| 848b3afe54 | |||
| dd86bae942 | |||
| 4691c61544 | |||
| dfb2d3b340 | |||
| 6a19ab05e3 | |||
| 7b718da7a2 | |||
| ebaf545418 | |||
| 2cdfdaed55 | |||
| 2216804652 | |||
| 1b177037f5 | |||
| 9d6590927c | |||
| eaf401200c | |||
| e97a4d53ae | |||
| ca2b3b25a5 | |||
| 19703de50d |
@@ -12,6 +12,8 @@ jobs:
|
|||||||
check:
|
check:
|
||||||
name: Type Check & Lint
|
name: Type Check & Lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: code.foss.global/host.today/ht-docker-node:latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -22,6 +24,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
deno-version: v2.x
|
deno-version: v2.x
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: deno install --entrypoint mod.ts
|
||||||
|
|
||||||
- name: Check TypeScript types
|
- name: Check TypeScript types
|
||||||
run: deno check mod.ts
|
run: deno check mod.ts
|
||||||
|
|
||||||
@@ -36,6 +41,8 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
name: Build Test (Current Platform)
|
name: Build Test (Current Platform)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: code.foss.global/host.today/ht-docker-node:latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -46,10 +53,21 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
deno-version: v2.x
|
deno-version: v2.x
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
|
||||||
|
- name: Enable corepack
|
||||||
|
run: corepack enable
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install --ignore-scripts
|
||||||
|
|
||||||
- name: Compile for current platform
|
- name: Compile for current platform
|
||||||
run: |
|
run: |
|
||||||
echo "Testing compilation for Linux x86_64..."
|
echo "Testing compilation for Linux x86_64..."
|
||||||
deno compile --allow-all --no-check \
|
npx tsdeno compile --allow-all --no-check \
|
||||||
--output onebox-test \
|
--output onebox-test \
|
||||||
--target x86_64-unknown-linux-gnu mod.ts
|
--target x86_64-unknown-linux-gnu mod.ts
|
||||||
|
|
||||||
@@ -62,6 +80,8 @@ jobs:
|
|||||||
build-all:
|
build-all:
|
||||||
name: Build All Platforms
|
name: Build All Platforms
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: code.foss.global/host.today/ht-docker-node:latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -72,8 +92,19 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
deno-version: v2.x
|
deno-version: v2.x
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
|
||||||
|
- name: Enable corepack
|
||||||
|
run: corepack enable
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install --ignore-scripts
|
||||||
|
|
||||||
- name: Compile all platform binaries
|
- name: Compile all platform binaries
|
||||||
run: bash scripts/compile-all.sh
|
run: mkdir -p dist/binaries && npx tsdeno compile
|
||||||
|
|
||||||
- name: Upload all binaries as artifact
|
- name: Upload all binaries as artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
npm-publish:
|
npm-publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: code.foss.global/host.today/ht-docker-node:latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build-and-release:
|
build-and-release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: code.foss.global/host.today/ht-docker-node:latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -20,6 +22,17 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
deno-version: v2.x
|
deno-version: v2.x
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
|
||||||
|
- name: Enable corepack
|
||||||
|
run: corepack enable
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install --ignore-scripts
|
||||||
|
|
||||||
- name: Get version from tag
|
- name: Get version from tag
|
||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
@@ -41,57 +54,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Compile binaries for all platforms
|
- name: Compile binaries for all platforms
|
||||||
run: |
|
run: mkdir -p dist/binaries && npx tsdeno compile
|
||||||
echo "================================================"
|
|
||||||
echo " Onebox Release Compilation"
|
|
||||||
echo " Version: ${{ steps.version.outputs.version }}"
|
|
||||||
echo "================================================"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Clean up old binaries and create fresh directory
|
|
||||||
rm -rf dist/binaries
|
|
||||||
mkdir -p dist/binaries
|
|
||||||
echo "-> Cleaned old binaries from dist/binaries"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Linux x86_64
|
|
||||||
echo "-> Compiling for Linux x86_64..."
|
|
||||||
deno compile --allow-all --no-check \
|
|
||||||
--output dist/binaries/onebox-linux-x64 \
|
|
||||||
--target x86_64-unknown-linux-gnu mod.ts
|
|
||||||
echo " Done: Linux x86_64"
|
|
||||||
|
|
||||||
# Linux ARM64
|
|
||||||
echo "-> Compiling for Linux ARM64..."
|
|
||||||
deno compile --allow-all --no-check \
|
|
||||||
--output dist/binaries/onebox-linux-arm64 \
|
|
||||||
--target aarch64-unknown-linux-gnu mod.ts
|
|
||||||
echo " Done: Linux ARM64"
|
|
||||||
|
|
||||||
# macOS x86_64
|
|
||||||
echo "-> Compiling for macOS x86_64..."
|
|
||||||
deno compile --allow-all --no-check \
|
|
||||||
--output dist/binaries/onebox-macos-x64 \
|
|
||||||
--target x86_64-apple-darwin mod.ts
|
|
||||||
echo " Done: macOS x86_64"
|
|
||||||
|
|
||||||
# macOS ARM64
|
|
||||||
echo "-> Compiling for macOS ARM64..."
|
|
||||||
deno compile --allow-all --no-check \
|
|
||||||
--output dist/binaries/onebox-macos-arm64 \
|
|
||||||
--target aarch64-apple-darwin mod.ts
|
|
||||||
echo " Done: macOS ARM64"
|
|
||||||
|
|
||||||
# Windows x86_64
|
|
||||||
echo "-> Compiling for Windows x86_64..."
|
|
||||||
deno compile --allow-all --no-check \
|
|
||||||
--output dist/binaries/onebox-windows-x64.exe \
|
|
||||||
--target x86_64-pc-windows-msvc mod.ts
|
|
||||||
echo " Done: Windows x86_64"
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "All binaries compiled successfully!"
|
|
||||||
ls -lh dist/binaries/
|
|
||||||
|
|
||||||
- name: Generate SHA256 checksums
|
- name: Generate SHA256 checksums
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
212
changelog.md
212
changelog.md
@@ -1,5 +1,217 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.18.3 - fix(deps)
|
||||||
|
bump @serve.zone/catalog to ^2.6.1
|
||||||
|
|
||||||
|
- Updates the @serve.zone/catalog runtime dependency from ^2.6.0 to ^2.6.1.
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.18.2 - fix(repo)
|
||||||
|
no changes to commit
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.18.1 - fix(repo)
|
||||||
|
no changes to commit
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.18.0 - feat(platform-services)
|
||||||
|
add platform service log retrieval and display in the services UI
|
||||||
|
|
||||||
|
- add typed request support in the ops server to fetch Docker logs for platform service containers
|
||||||
|
- store fetched platform service logs in web app state and load them when opening platform service details
|
||||||
|
- render platform service logs in the services detail view and add sidebar icons for main navigation tabs
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.17.4 - fix(docs)
|
||||||
|
add hello world running screenshot for documentation
|
||||||
|
|
||||||
|
- Adds a new PNG asset showing the application in a running hello world state.
|
||||||
|
- Supports project documentation or README usage without changing runtime behavior.
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.17.3 - fix(mongodb)
|
||||||
|
downgrade the MongoDB service image to 4.4 and use the legacy mongo shell for container operations
|
||||||
|
|
||||||
|
- changes the default MongoDB container image from mongo:7 to mongo:4.4
|
||||||
|
- replaces mongosh with mongo for health checks, provisioning, and deprovisioning inside the container
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.17.2 - fix(platform-services)
|
||||||
|
provision ClickHouse, MinIO, and MongoDB resources via docker exec instead of host port access
|
||||||
|
|
||||||
|
- switch ClickHouse provisioning and teardown to in-container client commands to avoid host port mapping issues
|
||||||
|
- replace MinIO host-side S3 API calls with in-container mc commands for bucket creation and removal
|
||||||
|
- run MongoDB provisioning and deprovisioning through mongosh inside the container and improve docker exec failure reporting
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.17.1 - fix(repo)
|
||||||
|
no changes to commit
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.17.0 - feat(web/services)
|
||||||
|
add deploy service action to the services view
|
||||||
|
|
||||||
|
- Adds a prominent "Deploy Service" button to the services page header.
|
||||||
|
- Routes users into the create service view directly from the services listing.
|
||||||
|
- Includes a new service creation form screenshot asset for the updated interface.
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.16.0 - feat(services)
|
||||||
|
add platform service navigation and stats in the services UI
|
||||||
|
|
||||||
|
- add platform service stats state and fetch action
|
||||||
|
- show platform services in the services list and open a platform detail view
|
||||||
|
- enable dashboard clicks to jump directly to the selected platform service
|
||||||
|
- refresh platform service stats after start and restart actions
|
||||||
|
- bump @serve.zone/catalog to ^2.6.0 for the new platform service UI components
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.15.3 - fix(install)
|
||||||
|
refresh systemd service configuration before restarting previously running installations
|
||||||
|
|
||||||
|
- Re-enable the systemd service during updates so unit file changes are applied before restart
|
||||||
|
- Add a log message indicating the service configuration is being refreshed
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.15.2 - fix(systemd)
|
||||||
|
set HOME and DENO_DIR for the systemd service environment
|
||||||
|
|
||||||
|
- Adds HOME=/root to the generated onebox systemd unit
|
||||||
|
- Adds DENO_DIR=/root/.cache/deno so Deno cache paths are available when running as a service
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.15.1 - fix(systemd)
|
||||||
|
move Docker installation and swarm initialization to systemd enable flow
|
||||||
|
|
||||||
|
- Ensures Docker is installed before writing and enabling the systemd unit that depends on docker.service.
|
||||||
|
- Removes Docker auto-installation from Onebox initialization so setup happens in the service management path.
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.15.0 - feat(systemd)
|
||||||
|
replace smartdaemon-based service management with native systemd commands
|
||||||
|
|
||||||
|
- adds a dedicated OneboxSystemd manager for enabling, disabling, starting, stopping, checking status, and following logs
|
||||||
|
- introduces a new `onebox systemd` CLI command set and updates install and help output to use it
|
||||||
|
- removes the smartdaemon dependency and related service management code
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.14.10 - fix(services)
|
||||||
|
stop auto-update monitoring during shutdown
|
||||||
|
|
||||||
|
- Track the auto-update polling interval in the services manager
|
||||||
|
- Clear the auto-update interval when Onebox shuts down to prevent background checks after shutdown
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.14.9 - fix(repo)
|
||||||
|
no changes to commit
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.14.8 - fix(repo)
|
||||||
|
no changes to commit
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.14.7 - fix(repo)
|
||||||
|
no changes to commit
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.14.6 - fix(project)
|
||||||
|
no changes to commit
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.14.5 - fix(onebox)
|
||||||
|
move Docker auto-install and swarm initialization into Onebox startup flow
|
||||||
|
|
||||||
|
- removes Docker setup from daemon service installation
|
||||||
|
- ensures Docker is installed before Docker initialization during Onebox startup
|
||||||
|
- preserves automatic Docker Swarm initialization on fresh servers
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.14.4 - fix(repo)
|
||||||
|
no changes to commit
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.14.3 - fix(repo)
|
||||||
|
no changes to commit
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.14.2 - fix(repo)
|
||||||
|
no changes to commit
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.14.1 - fix(repo)
|
||||||
|
no changes to commit
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.14.0 - feat(daemon)
|
||||||
|
auto-install Docker and initialize Swarm during daemon service setup
|
||||||
|
|
||||||
|
- Adds a Docker availability check before installing the Onebox daemon service
|
||||||
|
- Installs Docker automatically when it is missing using the standard installation script
|
||||||
|
- Attempts to initialize Docker Swarm after installation and handles already-initialized environments gracefully
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.13.17 - fix(ci)
|
||||||
|
remove forced container image pulling from Gitea workflow jobs
|
||||||
|
|
||||||
|
- Drops the `--pull always` container option from CI, npm publish, and release workflows.
|
||||||
|
- Keeps workflow container images unchanged while avoiding forced pulls on every job run.
|
||||||
|
|
||||||
|
## 2026-03-16 - 1.13.16 - fix(ci)
|
||||||
|
refresh workflow container images on every run and bump @apiclient.xyz/docker to ^5.1.1
|
||||||
|
|
||||||
|
- add --pull always to CI, release, and npm publish workflow containers to avoid stale images
|
||||||
|
- update @apiclient.xyz/docker from ^5.1.0 to ^5.1.1 in deno.json
|
||||||
|
|
||||||
|
## 2026-03-15 - 1.13.15 - fix(repo)
|
||||||
|
no changes to commit
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-03-15 - 1.13.14 - fix(repo)
|
||||||
|
no changes to commit
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-03-15 - 1.13.13 - fix(repo)
|
||||||
|
no changes to commit
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-03-15 - 1.13.12 - fix(ci)
|
||||||
|
run pnpm install with --ignore-scripts in CI and release workflows
|
||||||
|
|
||||||
|
- Update CI workflow dependency installation steps to skip lifecycle scripts during builds.
|
||||||
|
- Apply the same install change to the release workflow for consistent automation behavior.
|
||||||
|
|
||||||
|
## 2026-03-15 - 1.13.11 - fix(project)
|
||||||
|
no changes to commit
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-03-15 - 1.13.10 - fix(deps)
|
||||||
|
bump @git.zone/tsdeno to ^1.2.0
|
||||||
|
|
||||||
|
- Updates the tsdeno development dependency from ^1.1.1 to ^1.2.0.
|
||||||
|
|
||||||
|
## 2026-03-15 - 1.13.9 - fix(repo)
|
||||||
|
no changes to commit
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-03-15 - 1.13.8 - fix(repo)
|
||||||
|
no changes to commit
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-03-15 - 1.13.7 - fix(repo)
|
||||||
|
no changes to commit
|
||||||
|
|
||||||
|
|
||||||
|
## 2026-03-15 - 1.13.6 - fix(ci)
|
||||||
|
correct workflow container image registry path
|
||||||
|
|
||||||
|
- Update Gitea CI, release, and npm publish workflows to use the corrected ht-docker-node image path
|
||||||
|
- Align all workflow container references from hosttoday to host.today to prevent pipeline image resolution issues
|
||||||
|
|
||||||
|
## 2026-03-15 - 1.13.5 - fix(workflows)
|
||||||
|
switch Gitea workflow containers from ht-docker-dbase to ht-docker-node
|
||||||
|
|
||||||
|
- Updates the CI, release, and npm publish workflows to use the Node-focused container image consistently.
|
||||||
|
- Aligns workflow runtime images with the project's Node and Deno build and publish steps.
|
||||||
|
|
||||||
|
## 2026-03-15 - 1.13.4 - fix(ci)
|
||||||
|
run workflows in the shared build container and enable corepack for pnpm installs
|
||||||
|
|
||||||
|
- adds the ht-docker-dbase container image to CI, release, and npm publish workflows
|
||||||
|
- enables corepack before pnpm install in build and release jobs to ensure package manager availability
|
||||||
|
|
||||||
|
## 2026-03-15 - 1.13.3 - fix(build)
|
||||||
|
replace custom Deno compile scripts with tsdeno-based binary builds in CI and release workflows
|
||||||
|
|
||||||
|
- adds @git.zone/tsdeno as a dev dependency and configures compile targets in npmextra.json
|
||||||
|
- updates CI and release workflows to install Node.js dependencies before running tsdeno compile
|
||||||
|
- removes the legacy scripts/compile-all.sh script and points the compile task to tsdeno compile
|
||||||
|
|
||||||
## 2026-03-15 - 1.13.2 - fix(scripts)
|
## 2026-03-15 - 1.13.2 - fix(scripts)
|
||||||
install production dependencies before compiling binaries and exclude local node_modules from builds
|
install production dependencies before compiling binaries and exclude local node_modules from builds
|
||||||
|
|
||||||
|
|||||||
BIN
create-service-form.png
Normal file
BIN
create-service-form.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 59 KiB |
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "@serve.zone/onebox",
|
"name": "@serve.zone/onebox",
|
||||||
"version": "1.13.2",
|
"version": "1.18.3",
|
||||||
"exports": "./mod.ts",
|
"exports": "./mod.ts",
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"test": "deno test --allow-all test/",
|
"test": "deno test --allow-all test/",
|
||||||
"test:watch": "deno test --allow-all --watch test/",
|
"test:watch": "deno test --allow-all --watch test/",
|
||||||
"compile": "bash scripts/compile-all.sh",
|
"compile": "tsdeno compile",
|
||||||
"dev": "pnpm run watch"
|
"dev": "pnpm run watch"
|
||||||
},
|
},
|
||||||
"imports": {
|
"imports": {
|
||||||
@@ -15,8 +15,7 @@
|
|||||||
"@std/assert": "jsr:@std/assert@^1.0.15",
|
"@std/assert": "jsr:@std/assert@^1.0.15",
|
||||||
"@std/encoding": "jsr:@std/encoding@^1.0.10",
|
"@std/encoding": "jsr:@std/encoding@^1.0.10",
|
||||||
"@db/sqlite": "jsr:@db/sqlite@0.12.0",
|
"@db/sqlite": "jsr:@db/sqlite@0.12.0",
|
||||||
"@push.rocks/smartdaemon": "npm:@push.rocks/smartdaemon@^2.1.0",
|
"@apiclient.xyz/docker": "npm:@apiclient.xyz/docker@^5.1.1",
|
||||||
"@apiclient.xyz/docker": "npm:@apiclient.xyz/docker@^5.1.0",
|
|
||||||
"@apiclient.xyz/cloudflare": "npm:@apiclient.xyz/cloudflare@6.4.3",
|
"@apiclient.xyz/cloudflare": "npm:@apiclient.xyz/cloudflare@6.4.3",
|
||||||
"@push.rocks/smartacme": "npm:@push.rocks/smartacme@^8.0.0",
|
"@push.rocks/smartacme": "npm:@push.rocks/smartacme@^8.0.0",
|
||||||
"@push.rocks/smartregistry": "npm:@push.rocks/smartregistry@^2.2.0",
|
"@push.rocks/smartregistry": "npm:@push.rocks/smartregistry@^2.2.0",
|
||||||
|
|||||||
BIN
hello-world-running.png
Normal file
BIN
hello-world-running.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
16
install.sh
16
install.sh
@@ -23,7 +23,7 @@ SPECIFIED_VERSION=""
|
|||||||
INSTALL_DIR="/opt/onebox"
|
INSTALL_DIR="/opt/onebox"
|
||||||
GITEA_BASE_URL="https://code.foss.global"
|
GITEA_BASE_URL="https://code.foss.global"
|
||||||
GITEA_REPO="serve.zone/onebox"
|
GITEA_REPO="serve.zone/onebox"
|
||||||
SERVICE_NAME="smartdaemon_onebox"
|
SERVICE_NAME="onebox"
|
||||||
|
|
||||||
# Parse command line arguments
|
# Parse command line arguments
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
@@ -250,8 +250,10 @@ echo ""
|
|||||||
mkdir -p /var/lib/onebox
|
mkdir -p /var/lib/onebox
|
||||||
mkdir -p /var/www/certbot
|
mkdir -p /var/www/certbot
|
||||||
|
|
||||||
# Restart service if it was running before update
|
# Re-enable and restart service if it was previously running (refreshes unit file)
|
||||||
if [ $SERVICE_WAS_RUNNING -eq 1 ]; then
|
if [ $SERVICE_WAS_RUNNING -eq 1 ]; then
|
||||||
|
echo "Refreshing systemd service..."
|
||||||
|
onebox systemd enable
|
||||||
echo "Restarting Onebox service..."
|
echo "Restarting Onebox service..."
|
||||||
systemctl restart "$SERVICE_NAME"
|
systemctl restart "$SERVICE_NAME"
|
||||||
echo "Service restarted successfully."
|
echo "Service restarted successfully."
|
||||||
@@ -276,7 +278,7 @@ if [ -f "/var/lib/onebox/onebox.db" ]; then
|
|||||||
if [ $SERVICE_WAS_RUNNING -eq 1 ]; then
|
if [ $SERVICE_WAS_RUNNING -eq 1 ]; then
|
||||||
echo "The service has been restarted with your current settings."
|
echo "The service has been restarted with your current settings."
|
||||||
else
|
else
|
||||||
echo "Start the service with: onebox daemon start"
|
echo "Start the service with: onebox systemd start"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Get started:"
|
echo "Get started:"
|
||||||
@@ -293,11 +295,11 @@ else
|
|||||||
echo " 2. Configure ACME email:"
|
echo " 2. Configure ACME email:"
|
||||||
echo " onebox config set acmeEmail <your@email.com>"
|
echo " onebox config set acmeEmail <your@email.com>"
|
||||||
echo ""
|
echo ""
|
||||||
echo " 3. Install daemon:"
|
echo " 3. Enable systemd service:"
|
||||||
echo " onebox daemon install"
|
echo " onebox systemd enable"
|
||||||
echo ""
|
echo ""
|
||||||
echo " 4. Start daemon:"
|
echo " 4. Start service:"
|
||||||
echo " onebox daemon start"
|
echo " onebox systemd start"
|
||||||
echo ""
|
echo ""
|
||||||
echo " 5. Deploy your first service:"
|
echo " 5. Deploy your first service:"
|
||||||
echo " onebox service add myapp --image nginx:latest --domain app.example.com"
|
echo " onebox service add myapp --image nginx:latest --domain app.example.com"
|
||||||
|
|||||||
@@ -11,6 +11,26 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"@git.zone/tsdeno": {
|
||||||
|
"compileTargets": [
|
||||||
|
{
|
||||||
|
"name": "onebox-linux-x64",
|
||||||
|
"entryPoint": "mod.ts",
|
||||||
|
"outDir": "dist/binaries",
|
||||||
|
"target": "x86_64-unknown-linux-gnu",
|
||||||
|
"permissions": ["--allow-all"],
|
||||||
|
"noCheck": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "onebox-linux-arm64",
|
||||||
|
"entryPoint": "mod.ts",
|
||||||
|
"outDir": "dist/binaries",
|
||||||
|
"target": "aarch64-unknown-linux-gnu",
|
||||||
|
"permissions": ["--allow-all"],
|
||||||
|
"noCheck": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"@git.zone/tswatch": {
|
"@git.zone/tswatch": {
|
||||||
"bundles": [
|
"bundles": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@serve.zone/onebox",
|
"name": "@serve.zone/onebox",
|
||||||
"version": "1.13.2",
|
"version": "1.18.3",
|
||||||
"description": "Self-hosted container platform with automatic SSL and DNS - a mini Heroku for single servers",
|
"description": "Self-hosted container platform with automatic SSL and DNS - a mini Heroku for single servers",
|
||||||
"main": "mod.ts",
|
"main": "mod.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@@ -57,10 +57,11 @@
|
|||||||
"@api.global/typedrequest-interfaces": "^3.0.19",
|
"@api.global/typedrequest-interfaces": "^3.0.19",
|
||||||
"@design.estate/dees-catalog": "^3.43.3",
|
"@design.estate/dees-catalog": "^3.43.3",
|
||||||
"@design.estate/dees-element": "^2.1.6",
|
"@design.estate/dees-element": "^2.1.6",
|
||||||
"@serve.zone/catalog": "^2.5.0"
|
"@serve.zone/catalog": "^2.6.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbundle": "^2.9.0",
|
"@git.zone/tsbundle": "^2.9.0",
|
||||||
|
"@git.zone/tsdeno": "^1.2.0",
|
||||||
"@git.zone/tswatch": "^3.2.0"
|
"@git.zone/tswatch": "^3.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
939
pnpm-lock.yaml
generated
939
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,60 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Compile Onebox for all platforms
|
|
||||||
#
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
VERSION=$(grep '"version"' deno.json | cut -d'"' -f4)
|
|
||||||
echo "Compiling Onebox v${VERSION} for all platforms..."
|
|
||||||
|
|
||||||
# Install only transitively imported dependencies (skips devDependencies from package.json)
|
|
||||||
echo "Installing production dependencies..."
|
|
||||||
deno install --entrypoint mod.ts
|
|
||||||
|
|
||||||
# Create dist directory
|
|
||||||
mkdir -p dist/binaries
|
|
||||||
|
|
||||||
# Compile for each platform (--node-modules-dir=none avoids bundling local node_modules)
|
|
||||||
echo "Compiling for Linux x64..."
|
|
||||||
deno compile --allow-all --no-check --node-modules-dir=none \
|
|
||||||
--output "dist/binaries/onebox-linux-x64" \
|
|
||||||
--target x86_64-unknown-linux-gnu \
|
|
||||||
mod.ts
|
|
||||||
|
|
||||||
echo "Compiling for Linux ARM64..."
|
|
||||||
deno compile --allow-all --no-check --node-modules-dir=none \
|
|
||||||
--output "dist/binaries/onebox-linux-arm64" \
|
|
||||||
--target aarch64-unknown-linux-gnu \
|
|
||||||
mod.ts
|
|
||||||
|
|
||||||
echo "Compiling for macOS x64..."
|
|
||||||
deno compile --allow-all --no-check --node-modules-dir=none \
|
|
||||||
--output "dist/binaries/onebox-macos-x64" \
|
|
||||||
--target x86_64-apple-darwin \
|
|
||||||
mod.ts
|
|
||||||
|
|
||||||
echo "Compiling for macOS ARM64..."
|
|
||||||
deno compile --allow-all --no-check --node-modules-dir=none \
|
|
||||||
--output "dist/binaries/onebox-macos-arm64" \
|
|
||||||
--target aarch64-apple-darwin \
|
|
||||||
mod.ts
|
|
||||||
|
|
||||||
echo "Compiling for Windows x64..."
|
|
||||||
deno compile --allow-all --no-check --node-modules-dir=none \
|
|
||||||
--output "dist/binaries/onebox-windows-x64.exe" \
|
|
||||||
--target x86_64-pc-windows-msvc \
|
|
||||||
mod.ts
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "✓ Compilation complete!"
|
|
||||||
echo ""
|
|
||||||
echo "Binaries:"
|
|
||||||
ls -lh dist/binaries/
|
|
||||||
echo ""
|
|
||||||
echo "Next steps:"
|
|
||||||
echo "1. Test binaries on their respective platforms"
|
|
||||||
echo "2. Create git tag: git tag v${VERSION}"
|
|
||||||
echo "3. Push tag: git push origin v${VERSION}"
|
|
||||||
echo "4. Upload binaries to Gitea release"
|
|
||||||
echo "5. Publish to npm: pnpm publish"
|
|
||||||
BIN
sidebar-icons.png
Normal file
BIN
sidebar-icons.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 52 KiB |
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@serve.zone/onebox',
|
name: '@serve.zone/onebox',
|
||||||
version: '1.13.2',
|
version: '1.18.3',
|
||||||
description: 'Self-hosted container platform with automatic SSL and DNS - a mini Heroku for single servers'
|
description: 'Self-hosted container platform with automatic SSL and DNS - a mini Heroku for single servers'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,7 @@
|
|||||||
* Handles background monitoring, metrics collection, and automatic tasks
|
* Handles background monitoring, metrics collection, and automatic tasks
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as plugins from '../plugins.ts';
|
|
||||||
import { logger } from '../logging.ts';
|
import { logger } from '../logging.ts';
|
||||||
import { projectInfo } from '../info.ts';
|
|
||||||
import { getErrorMessage } from '../utils/error.ts';
|
import { getErrorMessage } from '../utils/error.ts';
|
||||||
import type { Onebox } from './onebox.ts';
|
import type { Onebox } from './onebox.ts';
|
||||||
|
|
||||||
@@ -18,7 +16,6 @@ const FALLBACK_PID_FILE = `${FALLBACK_PID_DIR}/onebox.pid`;
|
|||||||
|
|
||||||
export class OneboxDaemon {
|
export class OneboxDaemon {
|
||||||
private oneboxRef: Onebox;
|
private oneboxRef: Onebox;
|
||||||
private smartdaemon: plugins.smartdaemon.SmartDaemon | null = null;
|
|
||||||
private running = false;
|
private running = false;
|
||||||
private monitoringInterval: number | null = null;
|
private monitoringInterval: number | null = null;
|
||||||
private statsInterval: number | null = null;
|
private statsInterval: number | null = null;
|
||||||
@@ -46,68 +43,6 @@ export class OneboxDaemon {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Install systemd service
|
|
||||||
*/
|
|
||||||
async installService(): Promise<void> {
|
|
||||||
try {
|
|
||||||
logger.info('Installing Onebox daemon service...');
|
|
||||||
|
|
||||||
// Initialize smartdaemon if needed
|
|
||||||
if (!this.smartdaemon) {
|
|
||||||
this.smartdaemon = new plugins.smartdaemon.SmartDaemon();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get installation directory
|
|
||||||
const execPath = Deno.execPath();
|
|
||||||
|
|
||||||
const service = await this.smartdaemon.addService({
|
|
||||||
name: 'onebox',
|
|
||||||
version: projectInfo.version,
|
|
||||||
command: `${execPath} run --allow-all ${Deno.cwd()}/mod.ts daemon start`,
|
|
||||||
description: 'Onebox - Self-hosted container platform',
|
|
||||||
workingDir: Deno.cwd(),
|
|
||||||
});
|
|
||||||
|
|
||||||
await service.save();
|
|
||||||
await service.enable();
|
|
||||||
|
|
||||||
logger.success('Onebox daemon service installed');
|
|
||||||
logger.info('Start with: sudo systemctl start smartdaemon_onebox');
|
|
||||||
} catch (error) {
|
|
||||||
logger.error(`Failed to install daemon service: ${getErrorMessage(error)}`);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Uninstall systemd service
|
|
||||||
*/
|
|
||||||
async uninstallService(): Promise<void> {
|
|
||||||
try {
|
|
||||||
logger.info('Uninstalling Onebox daemon service...');
|
|
||||||
|
|
||||||
// Initialize smartdaemon if needed
|
|
||||||
if (!this.smartdaemon) {
|
|
||||||
this.smartdaemon = new plugins.smartdaemon.SmartDaemon();
|
|
||||||
}
|
|
||||||
|
|
||||||
const services = await this.smartdaemon.systemdManager.getServices();
|
|
||||||
const service = services.find(s => s.name === 'onebox');
|
|
||||||
|
|
||||||
if (service) {
|
|
||||||
await service.stop();
|
|
||||||
await service.disable();
|
|
||||||
await service.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.success('Onebox daemon service uninstalled');
|
|
||||||
} catch (error) {
|
|
||||||
logger.error(`Failed to uninstall daemon service: ${getErrorMessage(error)}`);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start daemon mode (background monitoring)
|
* Start daemon mode (background monitoring)
|
||||||
*/
|
*/
|
||||||
@@ -482,36 +417,7 @@ export class OneboxDaemon {
|
|||||||
static async ensureNoDaemon(): Promise<void> {
|
static async ensureNoDaemon(): Promise<void> {
|
||||||
const running = await OneboxDaemon.isDaemonRunning();
|
const running = await OneboxDaemon.isDaemonRunning();
|
||||||
if (running) {
|
if (running) {
|
||||||
throw new Error('Daemon is already running. Please stop it first with: onebox daemon stop');
|
throw new Error('Daemon is already running. Please stop it first with: onebox systemd stop');
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get service status from systemd
|
|
||||||
*/
|
|
||||||
async getServiceStatus(): Promise<string> {
|
|
||||||
try {
|
|
||||||
// Don't need smartdaemon to check status, just use systemctl directly
|
|
||||||
const command = new Deno.Command('systemctl', {
|
|
||||||
args: ['status', 'smartdaemon_onebox'],
|
|
||||||
stdout: 'piped',
|
|
||||||
stderr: 'piped',
|
|
||||||
});
|
|
||||||
|
|
||||||
const { code, stdout } = await command.output();
|
|
||||||
const output = new TextDecoder().decode(stdout);
|
|
||||||
|
|
||||||
if (code === 0 || output.includes('active (running)')) {
|
|
||||||
return 'running';
|
|
||||||
} else if (output.includes('inactive') || output.includes('dead')) {
|
|
||||||
return 'stopped';
|
|
||||||
} else if (output.includes('failed')) {
|
|
||||||
return 'failed';
|
|
||||||
} else {
|
|
||||||
return 'unknown';
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
return 'not-installed';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -881,12 +881,12 @@ export class OneboxDockerManager {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const execInfo = await inspect();
|
const execInfo = await inspect();
|
||||||
const exitCode = execInfo.ExitCode || 0;
|
const exitCode = execInfo.ExitCode ?? -1;
|
||||||
|
|
||||||
return { stdout, stderr, exitCode };
|
return { stdout, stderr, exitCode };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(`Failed to exec in container ${containerID}: ${getErrorMessage(error)}`);
|
logger.error(`Failed to exec in container ${containerID}: ${getErrorMessage(error)}`);
|
||||||
throw error;
|
return { stdout: '', stderr: getErrorMessage(error), exitCode: -1 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { OneboxReverseProxy } from './reverseproxy.ts';
|
|||||||
import { OneboxDnsManager } from './dns.ts';
|
import { OneboxDnsManager } from './dns.ts';
|
||||||
import { OneboxSslManager } from './ssl.ts';
|
import { OneboxSslManager } from './ssl.ts';
|
||||||
import { OneboxDaemon } from './daemon.ts';
|
import { OneboxDaemon } from './daemon.ts';
|
||||||
|
import { OneboxSystemd } from './systemd.ts';
|
||||||
import { OneboxHttpServer } from './httpserver.ts';
|
import { OneboxHttpServer } from './httpserver.ts';
|
||||||
import { CloudflareDomainSync } from './cloudflare-sync.ts';
|
import { CloudflareDomainSync } from './cloudflare-sync.ts';
|
||||||
import { CertRequirementManager } from './cert-requirement-manager.ts';
|
import { CertRequirementManager } from './cert-requirement-manager.ts';
|
||||||
@@ -33,6 +34,7 @@ export class Onebox {
|
|||||||
public dns: OneboxDnsManager;
|
public dns: OneboxDnsManager;
|
||||||
public ssl: OneboxSslManager;
|
public ssl: OneboxSslManager;
|
||||||
public daemon: OneboxDaemon;
|
public daemon: OneboxDaemon;
|
||||||
|
public systemd: OneboxSystemd;
|
||||||
public httpServer: OneboxHttpServer;
|
public httpServer: OneboxHttpServer;
|
||||||
public cloudflareDomainSync: CloudflareDomainSync;
|
public cloudflareDomainSync: CloudflareDomainSync;
|
||||||
public certRequirementManager: CertRequirementManager;
|
public certRequirementManager: CertRequirementManager;
|
||||||
@@ -57,6 +59,7 @@ export class Onebox {
|
|||||||
this.dns = new OneboxDnsManager(this);
|
this.dns = new OneboxDnsManager(this);
|
||||||
this.ssl = new OneboxSslManager(this);
|
this.ssl = new OneboxSslManager(this);
|
||||||
this.daemon = new OneboxDaemon(this);
|
this.daemon = new OneboxDaemon(this);
|
||||||
|
this.systemd = new OneboxSystemd();
|
||||||
this.httpServer = new OneboxHttpServer(this);
|
this.httpServer = new OneboxHttpServer(this);
|
||||||
this.registry = new RegistryManager({
|
this.registry = new RegistryManager({
|
||||||
dataDir: './.nogit/registry-data',
|
dataDir: './.nogit/registry-data',
|
||||||
@@ -320,20 +323,6 @@ export class Onebox {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Start daemon mode
|
|
||||||
*/
|
|
||||||
async startDaemon(): Promise<void> {
|
|
||||||
await this.daemon.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stop daemon mode
|
|
||||||
*/
|
|
||||||
async stopDaemon(): Promise<void> {
|
|
||||||
await this.daemon.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start OpsServer (TypedRequest-based, serves new UI)
|
* Start OpsServer (TypedRequest-based, serves new UI)
|
||||||
*/
|
*/
|
||||||
@@ -355,6 +344,9 @@ export class Onebox {
|
|||||||
try {
|
try {
|
||||||
logger.info('Shutting down Onebox...');
|
logger.info('Shutting down Onebox...');
|
||||||
|
|
||||||
|
// Stop auto-update monitoring
|
||||||
|
this.services.stopAutoUpdateMonitoring();
|
||||||
|
|
||||||
// Stop backup scheduler
|
// Stop backup scheduler
|
||||||
await this.backupScheduler.stop();
|
await this.backupScheduler.stop();
|
||||||
|
|
||||||
|
|||||||
@@ -194,12 +194,6 @@ export class ClickHouseProvider extends BasePlatformServiceProvider {
|
|||||||
const adminCreds = await credentialEncryption.decrypt(platformService.adminCredentialsEncrypted);
|
const adminCreds = await credentialEncryption.decrypt(platformService.adminCredentialsEncrypted);
|
||||||
const containerName = this.getContainerName();
|
const containerName = this.getContainerName();
|
||||||
|
|
||||||
// Get container host port for connection from host (overlay network IPs not accessible from host)
|
|
||||||
const hostPort = await this.oneboxRef.docker.getContainerHostPort(platformService.containerId, 8123);
|
|
||||||
if (!hostPort) {
|
|
||||||
throw new Error('Could not get ClickHouse container host port');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate resource names and credentials
|
// Generate resource names and credentials
|
||||||
const dbName = this.generateResourceName(userService.name);
|
const dbName = this.generateResourceName(userService.name);
|
||||||
const username = this.generateResourceName(userService.name);
|
const username = this.generateResourceName(userService.name);
|
||||||
@@ -207,35 +201,16 @@ export class ClickHouseProvider extends BasePlatformServiceProvider {
|
|||||||
|
|
||||||
logger.info(`Provisioning ClickHouse database '${dbName}' for service '${userService.name}'...`);
|
logger.info(`Provisioning ClickHouse database '${dbName}' for service '${userService.name}'...`);
|
||||||
|
|
||||||
// Connect to ClickHouse via localhost and the mapped host port
|
// Use docker exec to provision inside the container (avoids host port mapping issues)
|
||||||
const baseUrl = `http://127.0.0.1:${hostPort}`;
|
const queries = [
|
||||||
|
`CREATE DATABASE IF NOT EXISTS ${dbName}`,
|
||||||
|
`CREATE USER IF NOT EXISTS ${username} IDENTIFIED BY '${password}'`,
|
||||||
|
`GRANT ALL ON ${dbName}.* TO ${username}`,
|
||||||
|
];
|
||||||
|
|
||||||
// Create database
|
for (const query of queries) {
|
||||||
await this.executeQuery(
|
await this.execClickHouseQuery(platformService.containerId, adminCreds, query);
|
||||||
baseUrl,
|
}
|
||||||
adminCreds.username,
|
|
||||||
adminCreds.password,
|
|
||||||
`CREATE DATABASE IF NOT EXISTS ${dbName}`
|
|
||||||
);
|
|
||||||
logger.info(`Created ClickHouse database '${dbName}'`);
|
|
||||||
|
|
||||||
// Create user with access to this database
|
|
||||||
await this.executeQuery(
|
|
||||||
baseUrl,
|
|
||||||
adminCreds.username,
|
|
||||||
adminCreds.password,
|
|
||||||
`CREATE USER IF NOT EXISTS ${username} IDENTIFIED BY '${password}'`
|
|
||||||
);
|
|
||||||
logger.info(`Created ClickHouse user '${username}'`);
|
|
||||||
|
|
||||||
// Grant permissions on the database
|
|
||||||
await this.executeQuery(
|
|
||||||
baseUrl,
|
|
||||||
adminCreds.username,
|
|
||||||
adminCreds.password,
|
|
||||||
`GRANT ALL ON ${dbName}.* TO ${username}`
|
|
||||||
);
|
|
||||||
logger.info(`Granted permissions to user '${username}' on database '${dbName}'`);
|
|
||||||
|
|
||||||
logger.success(`ClickHouse database '${dbName}' provisioned with user '${username}'`);
|
logger.success(`ClickHouse database '${dbName}' provisioned with user '${username}'`);
|
||||||
|
|
||||||
@@ -274,37 +249,11 @@ export class ClickHouseProvider extends BasePlatformServiceProvider {
|
|||||||
|
|
||||||
const adminCreds = await credentialEncryption.decrypt(platformService.adminCredentialsEncrypted);
|
const adminCreds = await credentialEncryption.decrypt(platformService.adminCredentialsEncrypted);
|
||||||
|
|
||||||
// Get container host port for connection from host (overlay network IPs not accessible from host)
|
|
||||||
const hostPort = await this.oneboxRef.docker.getContainerHostPort(platformService.containerId, 8123);
|
|
||||||
if (!hostPort) {
|
|
||||||
throw new Error('Could not get ClickHouse container host port');
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info(`Deprovisioning ClickHouse database '${resource.resourceName}'...`);
|
logger.info(`Deprovisioning ClickHouse database '${resource.resourceName}'...`);
|
||||||
|
|
||||||
const baseUrl = `http://127.0.0.1:${hostPort}`;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Drop the user
|
await this.execClickHouseQuery(platformService.containerId, adminCreds, `DROP USER IF EXISTS ${credentials.username}`);
|
||||||
try {
|
await this.execClickHouseQuery(platformService.containerId, adminCreds, `DROP DATABASE IF EXISTS ${resource.resourceName}`);
|
||||||
await this.executeQuery(
|
|
||||||
baseUrl,
|
|
||||||
adminCreds.username,
|
|
||||||
adminCreds.password,
|
|
||||||
`DROP USER IF EXISTS ${credentials.username}`
|
|
||||||
);
|
|
||||||
logger.info(`Dropped ClickHouse user '${credentials.username}'`);
|
|
||||||
} catch (e) {
|
|
||||||
logger.warn(`Could not drop ClickHouse user: ${getErrorMessage(e)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Drop the database
|
|
||||||
await this.executeQuery(
|
|
||||||
baseUrl,
|
|
||||||
adminCreds.username,
|
|
||||||
adminCreds.password,
|
|
||||||
`DROP DATABASE IF EXISTS ${resource.resourceName}`
|
|
||||||
);
|
|
||||||
logger.success(`ClickHouse database '${resource.resourceName}' dropped`);
|
logger.success(`ClickHouse database '${resource.resourceName}' dropped`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error(`Failed to deprovision ClickHouse database: ${getErrorMessage(e)}`);
|
logger.error(`Failed to deprovision ClickHouse database: ${getErrorMessage(e)}`);
|
||||||
@@ -313,26 +262,27 @@ export class ClickHouseProvider extends BasePlatformServiceProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute a ClickHouse SQL query via HTTP interface
|
* Execute a ClickHouse SQL query via docker exec inside the container
|
||||||
*/
|
*/
|
||||||
private async executeQuery(
|
private async execClickHouseQuery(
|
||||||
baseUrl: string,
|
containerId: string,
|
||||||
username: string,
|
adminCreds: { username: string; password: string },
|
||||||
password: string,
|
|
||||||
query: string
|
query: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const url = `${baseUrl}/?user=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}`;
|
const result = await this.oneboxRef.docker.execInContainer(
|
||||||
|
containerId,
|
||||||
|
[
|
||||||
|
'clickhouse-client',
|
||||||
|
'--user', adminCreds.username,
|
||||||
|
'--password', adminCreds.password,
|
||||||
|
'--query', query,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
const response = await fetch(url, {
|
if (result.exitCode !== 0) {
|
||||||
method: 'POST',
|
throw new Error(`ClickHouse query failed (exit ${result.exitCode}): ${result.stderr.substring(0, 200)}`);
|
||||||
body: query,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
const errorText = await response.text();
|
|
||||||
throw new Error(`ClickHouse query failed: ${errorText}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return await response.text();
|
return result.stdout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,84 +196,28 @@ export class MinioProvider extends BasePlatformServiceProvider {
|
|||||||
const adminCreds = await credentialEncryption.decrypt(platformService.adminCredentialsEncrypted);
|
const adminCreds = await credentialEncryption.decrypt(platformService.adminCredentialsEncrypted);
|
||||||
const containerName = this.getContainerName();
|
const containerName = this.getContainerName();
|
||||||
|
|
||||||
// Get container host port for connection from host (overlay network IPs not accessible from host)
|
// Generate bucket name
|
||||||
const hostPort = await this.oneboxRef.docker.getContainerHostPort(platformService.containerId, 9000);
|
|
||||||
if (!hostPort) {
|
|
||||||
throw new Error('Could not get MinIO container host port');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate bucket name and credentials
|
|
||||||
const bucketName = this.generateBucketName(userService.name);
|
const bucketName = this.generateBucketName(userService.name);
|
||||||
const accessKey = credentialEncryption.generateAccessKey(20);
|
|
||||||
const secretKey = credentialEncryption.generateSecretKey(40);
|
|
||||||
|
|
||||||
logger.info(`Provisioning MinIO bucket '${bucketName}' for service '${userService.name}'...`);
|
logger.info(`Provisioning MinIO bucket '${bucketName}' for service '${userService.name}'...`);
|
||||||
|
|
||||||
// Connect to MinIO via localhost and the mapped host port (for provisioning from host)
|
// Use docker exec with mc (MinIO Client) inside the container
|
||||||
const provisioningEndpoint = `http://127.0.0.1:${hostPort}`;
|
// First configure mc alias for local server
|
||||||
|
await this.execMc(platformService.containerId, [
|
||||||
// Import AWS S3 client
|
'alias', 'set', 'local', 'http://localhost:9000',
|
||||||
const { S3Client, CreateBucketCommand, PutBucketPolicyCommand } = await import('npm:@aws-sdk/client-s3@3');
|
adminCreds.username, adminCreds.password,
|
||||||
|
]);
|
||||||
// Create S3 client with admin credentials - connect via host port
|
|
||||||
const s3Client = new S3Client({
|
|
||||||
endpoint: provisioningEndpoint,
|
|
||||||
region: 'us-east-1',
|
|
||||||
credentials: {
|
|
||||||
accessKeyId: adminCreds.username,
|
|
||||||
secretAccessKey: adminCreds.password,
|
|
||||||
},
|
|
||||||
forcePathStyle: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create the bucket
|
// Create the bucket
|
||||||
try {
|
const mbResult = await this.execMc(platformService.containerId, [
|
||||||
await s3Client.send(new CreateBucketCommand({
|
'mb', '--ignore-existing', `local/${bucketName}`,
|
||||||
Bucket: bucketName,
|
]);
|
||||||
}));
|
logger.info(`Created MinIO bucket '${bucketName}'`);
|
||||||
logger.info(`Created MinIO bucket '${bucketName}'`);
|
|
||||||
} catch (e: any) {
|
|
||||||
if (e.name !== 'BucketAlreadyOwnedByYou' && e.name !== 'BucketAlreadyExists') {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
logger.warn(`Bucket '${bucketName}' already exists`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create service account/access key using MinIO Admin API
|
// Set bucket policy to allow public read/write (services on the same network use root creds)
|
||||||
// MinIO Admin API requires mc client or direct API calls
|
await this.execMc(platformService.containerId, [
|
||||||
// For simplicity, we'll use root credentials and bucket policy isolation
|
'anonymous', 'set', 'none', `local/${bucketName}`,
|
||||||
// In production, you'd use MinIO's Admin API to create service accounts
|
]);
|
||||||
|
|
||||||
// Set bucket policy to allow access only with this bucket's credentials
|
|
||||||
const bucketPolicy = {
|
|
||||||
Version: '2012-10-17',
|
|
||||||
Statement: [
|
|
||||||
{
|
|
||||||
Effect: 'Allow',
|
|
||||||
Principal: { AWS: ['*'] },
|
|
||||||
Action: ['s3:GetObject', 's3:PutObject', 's3:DeleteObject', 's3:ListBucket'],
|
|
||||||
Resource: [
|
|
||||||
`arn:aws:s3:::${bucketName}`,
|
|
||||||
`arn:aws:s3:::${bucketName}/*`,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
await s3Client.send(new PutBucketPolicyCommand({
|
|
||||||
Bucket: bucketName,
|
|
||||||
Policy: JSON.stringify(bucketPolicy),
|
|
||||||
}));
|
|
||||||
logger.info(`Set bucket policy for '${bucketName}'`);
|
|
||||||
} catch (e) {
|
|
||||||
logger.warn(`Could not set bucket policy: ${getErrorMessage(e)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: For proper per-service credentials, MinIO Admin API should be used
|
|
||||||
// For now, we're providing the bucket with root access
|
|
||||||
// TODO: Implement MinIO service account creation
|
|
||||||
logger.warn('Using root credentials for MinIO access. Consider implementing service accounts for production.');
|
|
||||||
|
|
||||||
// Use container name for the endpoint in credentials (user services run in same network)
|
// Use container name for the endpoint in credentials (user services run in same network)
|
||||||
const serviceEndpoint = `http://${containerName}:9000`;
|
const serviceEndpoint = `http://${containerName}:9000`;
|
||||||
@@ -281,7 +225,7 @@ export class MinioProvider extends BasePlatformServiceProvider {
|
|||||||
const credentials: Record<string, string> = {
|
const credentials: Record<string, string> = {
|
||||||
endpoint: serviceEndpoint,
|
endpoint: serviceEndpoint,
|
||||||
bucket: bucketName,
|
bucket: bucketName,
|
||||||
accessKey: adminCreds.username, // Using root for now
|
accessKey: adminCreds.username,
|
||||||
secretKey: adminCreds.password,
|
secretKey: adminCreds.password,
|
||||||
region: 'us-east-1',
|
region: 'us-east-1',
|
||||||
};
|
};
|
||||||
@@ -312,57 +256,37 @@ export class MinioProvider extends BasePlatformServiceProvider {
|
|||||||
|
|
||||||
const adminCreds = await credentialEncryption.decrypt(platformService.adminCredentialsEncrypted);
|
const adminCreds = await credentialEncryption.decrypt(platformService.adminCredentialsEncrypted);
|
||||||
|
|
||||||
// Get container host port for connection from host (overlay network IPs not accessible from host)
|
|
||||||
const hostPort = await this.oneboxRef.docker.getContainerHostPort(platformService.containerId, 9000);
|
|
||||||
if (!hostPort) {
|
|
||||||
throw new Error('Could not get MinIO container host port');
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info(`Deprovisioning MinIO bucket '${resource.resourceName}'...`);
|
logger.info(`Deprovisioning MinIO bucket '${resource.resourceName}'...`);
|
||||||
|
|
||||||
const { S3Client, DeleteBucketCommand, ListObjectsV2Command, DeleteObjectsCommand } = await import('npm:@aws-sdk/client-s3@3');
|
// Configure mc alias
|
||||||
|
await this.execMc(platformService.containerId, [
|
||||||
const s3Client = new S3Client({
|
'alias', 'set', 'local', 'http://localhost:9000',
|
||||||
endpoint: `http://127.0.0.1:${hostPort}`,
|
adminCreds.username, adminCreds.password,
|
||||||
region: 'us-east-1',
|
]);
|
||||||
credentials: {
|
|
||||||
accessKeyId: adminCreds.username,
|
|
||||||
secretAccessKey: adminCreds.password,
|
|
||||||
},
|
|
||||||
forcePathStyle: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// First, delete all objects in the bucket
|
// Remove all objects and the bucket
|
||||||
let continuationToken: string | undefined;
|
await this.execMc(platformService.containerId, [
|
||||||
do {
|
'rb', '--force', `local/${resource.resourceName}`,
|
||||||
const listResponse = await s3Client.send(new ListObjectsV2Command({
|
]);
|
||||||
Bucket: resource.resourceName,
|
|
||||||
ContinuationToken: continuationToken,
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (listResponse.Contents && listResponse.Contents.length > 0) {
|
|
||||||
await s3Client.send(new DeleteObjectsCommand({
|
|
||||||
Bucket: resource.resourceName,
|
|
||||||
Delete: {
|
|
||||||
Objects: listResponse.Contents.map(obj => ({ Key: obj.Key! })),
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
logger.info(`Deleted ${listResponse.Contents.length} objects from bucket`);
|
|
||||||
}
|
|
||||||
|
|
||||||
continuationToken = listResponse.IsTruncated ? listResponse.NextContinuationToken : undefined;
|
|
||||||
} while (continuationToken);
|
|
||||||
|
|
||||||
// Now delete the bucket
|
|
||||||
await s3Client.send(new DeleteBucketCommand({
|
|
||||||
Bucket: resource.resourceName,
|
|
||||||
}));
|
|
||||||
|
|
||||||
logger.success(`MinIO bucket '${resource.resourceName}' deleted`);
|
logger.success(`MinIO bucket '${resource.resourceName}' deleted`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error(`Failed to delete MinIO bucket: ${getErrorMessage(e)}`);
|
logger.error(`Failed to delete MinIO bucket: ${getErrorMessage(e)}`);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute mc (MinIO Client) command inside the container
|
||||||
|
*/
|
||||||
|
private async execMc(
|
||||||
|
containerId: string,
|
||||||
|
args: string[],
|
||||||
|
): Promise<{ stdout: string; stderr: string }> {
|
||||||
|
const result = await this.oneboxRef.docker.execInContainer(containerId, ['mc', ...args]);
|
||||||
|
if (result.exitCode !== 0) {
|
||||||
|
throw new Error(`mc command failed (exit ${result.exitCode}): ${result.stderr.substring(0, 200)}`);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export class MongoDBProvider extends BasePlatformServiceProvider {
|
|||||||
|
|
||||||
getDefaultConfig(): IPlatformServiceConfig {
|
getDefaultConfig(): IPlatformServiceConfig {
|
||||||
return {
|
return {
|
||||||
image: 'mongo:7',
|
image: 'mongo:4.4',
|
||||||
port: 27017,
|
port: 27017,
|
||||||
volumes: ['/var/lib/onebox/mongodb:/data/db'],
|
volumes: ['/var/lib/onebox/mongodb:/data/db'],
|
||||||
environment: {
|
environment: {
|
||||||
@@ -165,7 +165,7 @@ export class MongoDBProvider extends BasePlatformServiceProvider {
|
|||||||
// This avoids network issues with overlay networks
|
// This avoids network issues with overlay networks
|
||||||
const result = await this.oneboxRef.docker.execInContainer(
|
const result = await this.oneboxRef.docker.execInContainer(
|
||||||
platformService.containerId,
|
platformService.containerId,
|
||||||
['mongosh', '--eval', 'db.adminCommand("ping")', '--username', adminCreds.username, '--password', adminCreds.password, '--authenticationDatabase', 'admin', '--quiet']
|
['mongo', '--eval', 'db.adminCommand("ping")', '--username', adminCreds.username, '--password', adminCreds.password, '--authenticationDatabase', 'admin', '--quiet']
|
||||||
);
|
);
|
||||||
|
|
||||||
if (result.exitCode === 0) {
|
if (result.exitCode === 0) {
|
||||||
@@ -190,12 +190,6 @@ export class MongoDBProvider extends BasePlatformServiceProvider {
|
|||||||
const adminCreds = await credentialEncryption.decrypt(platformService.adminCredentialsEncrypted);
|
const adminCreds = await credentialEncryption.decrypt(platformService.adminCredentialsEncrypted);
|
||||||
const containerName = this.getContainerName();
|
const containerName = this.getContainerName();
|
||||||
|
|
||||||
// Get container host port for connection from host (overlay network IPs not accessible from host)
|
|
||||||
const hostPort = await this.oneboxRef.docker.getContainerHostPort(platformService.containerId, 27017);
|
|
||||||
if (!hostPort) {
|
|
||||||
throw new Error('Could not get MongoDB container host port');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate resource names and credentials
|
// Generate resource names and credentials
|
||||||
const dbName = this.generateResourceName(userService.name);
|
const dbName = this.generateResourceName(userService.name);
|
||||||
const username = this.generateResourceName(userService.name);
|
const username = this.generateResourceName(userService.name);
|
||||||
@@ -203,32 +197,40 @@ export class MongoDBProvider extends BasePlatformServiceProvider {
|
|||||||
|
|
||||||
logger.info(`Provisioning MongoDB database '${dbName}' for service '${userService.name}'...`);
|
logger.info(`Provisioning MongoDB database '${dbName}' for service '${userService.name}'...`);
|
||||||
|
|
||||||
// Connect to MongoDB via localhost and the mapped host port
|
// Use docker exec to provision inside the container (avoids host port mapping issues)
|
||||||
const { MongoClient } = await import('npm:mongodb@6');
|
const escapedPassword = password.replace(/'/g, "'\\''");
|
||||||
const adminUri = `mongodb://${adminCreds.username}:${adminCreds.password}@127.0.0.1:${hostPort}/?authSource=admin`;
|
const escapedAdminPassword = adminCreds.password.replace(/'/g, "'\\''");
|
||||||
|
|
||||||
const client = new MongoClient(adminUri);
|
// Create database and user via mongo inside the container
|
||||||
await client.connect();
|
const mongoScript = `
|
||||||
|
db = db.getSiblingDB('${dbName}');
|
||||||
try {
|
db.createCollection('_onebox_init');
|
||||||
// Create the database by switching to it (MongoDB creates on first write)
|
db.createUser({
|
||||||
const db = client.db(dbName);
|
user: '${username}',
|
||||||
|
pwd: '${escapedPassword}',
|
||||||
// Create a collection to ensure the database exists
|
roles: [{ role: 'readWrite', db: '${dbName}' }]
|
||||||
await db.createCollection('_onebox_init');
|
|
||||||
|
|
||||||
// Create user with readWrite access to this database
|
|
||||||
await db.command({
|
|
||||||
createUser: username,
|
|
||||||
pwd: password,
|
|
||||||
roles: [{ role: 'readWrite', db: dbName }],
|
|
||||||
});
|
});
|
||||||
|
print('PROVISION_SUCCESS');
|
||||||
|
`;
|
||||||
|
|
||||||
logger.success(`MongoDB database '${dbName}' provisioned with user '${username}'`);
|
const result = await this.oneboxRef.docker.execInContainer(
|
||||||
} finally {
|
platformService.containerId,
|
||||||
await client.close();
|
[
|
||||||
|
'mongo',
|
||||||
|
'--username', adminCreds.username,
|
||||||
|
'--password', escapedAdminPassword,
|
||||||
|
'--authenticationDatabase', 'admin',
|
||||||
|
'--quiet',
|
||||||
|
'--eval', mongoScript,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result.exitCode !== 0 || !result.stdout.includes('PROVISION_SUCCESS')) {
|
||||||
|
throw new Error(`Failed to provision MongoDB database: exit code ${result.exitCode}, output: ${result.stdout.substring(0, 200)} ${result.stderr.substring(0, 200)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.success(`MongoDB database '${dbName}' provisioned with user '${username}'`);
|
||||||
|
|
||||||
// Build the credentials and env vars
|
// Build the credentials and env vars
|
||||||
const credentials: Record<string, string> = {
|
const credentials: Record<string, string> = {
|
||||||
host: containerName,
|
host: containerName,
|
||||||
@@ -262,37 +264,33 @@ export class MongoDBProvider extends BasePlatformServiceProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const adminCreds = await credentialEncryption.decrypt(platformService.adminCredentialsEncrypted);
|
const adminCreds = await credentialEncryption.decrypt(platformService.adminCredentialsEncrypted);
|
||||||
|
const escapedAdminPassword = adminCreds.password.replace(/'/g, "'\\''");
|
||||||
// Get container host port for connection from host (overlay network IPs not accessible from host)
|
|
||||||
const hostPort = await this.oneboxRef.docker.getContainerHostPort(platformService.containerId, 27017);
|
|
||||||
if (!hostPort) {
|
|
||||||
throw new Error('Could not get MongoDB container host port');
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info(`Deprovisioning MongoDB database '${resource.resourceName}'...`);
|
logger.info(`Deprovisioning MongoDB database '${resource.resourceName}'...`);
|
||||||
|
|
||||||
const { MongoClient } = await import('npm:mongodb@6');
|
const mongoScript = `
|
||||||
const adminUri = `mongodb://${adminCreds.username}:${adminCreds.password}@127.0.0.1:${hostPort}/?authSource=admin`;
|
db = db.getSiblingDB('${resource.resourceName}');
|
||||||
|
try { db.dropUser('${credentials.username}'); } catch(e) { print('User drop failed: ' + e); }
|
||||||
|
db.dropDatabase();
|
||||||
|
print('DEPROVISION_SUCCESS');
|
||||||
|
`;
|
||||||
|
|
||||||
const client = new MongoClient(adminUri);
|
const result = await this.oneboxRef.docker.execInContainer(
|
||||||
await client.connect();
|
platformService.containerId,
|
||||||
|
[
|
||||||
|
'mongo',
|
||||||
|
'--username', adminCreds.username,
|
||||||
|
'--password', escapedAdminPassword,
|
||||||
|
'--authenticationDatabase', 'admin',
|
||||||
|
'--quiet',
|
||||||
|
'--eval', mongoScript,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
try {
|
if (result.exitCode !== 0) {
|
||||||
const db = client.db(resource.resourceName);
|
logger.warn(`MongoDB deprovision returned exit code ${result.exitCode}: ${result.stderr.substring(0, 200)}`);
|
||||||
|
|
||||||
// Drop the user
|
|
||||||
try {
|
|
||||||
await db.command({ dropUser: credentials.username });
|
|
||||||
logger.info(`Dropped MongoDB user '${credentials.username}'`);
|
|
||||||
} catch (e) {
|
|
||||||
logger.warn(`Could not drop MongoDB user: ${getErrorMessage(e)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Drop the database
|
|
||||||
await db.dropDatabase();
|
|
||||||
logger.success(`MongoDB database '${resource.resourceName}' dropped`);
|
|
||||||
} finally {
|
|
||||||
await client.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.success(`MongoDB database '${resource.resourceName}' dropped`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export class OneboxServicesManager {
|
|||||||
private oneboxRef: any; // Will be Onebox instance
|
private oneboxRef: any; // Will be Onebox instance
|
||||||
private database: OneboxDatabase;
|
private database: OneboxDatabase;
|
||||||
private docker: OneboxDockerManager;
|
private docker: OneboxDockerManager;
|
||||||
|
private autoUpdateIntervalId: number | null = null;
|
||||||
|
|
||||||
constructor(oneboxRef: any) {
|
constructor(oneboxRef: any) {
|
||||||
this.oneboxRef = oneboxRef;
|
this.oneboxRef = oneboxRef;
|
||||||
@@ -681,7 +682,7 @@ export class OneboxServicesManager {
|
|||||||
*/
|
*/
|
||||||
startAutoUpdateMonitoring(): void {
|
startAutoUpdateMonitoring(): void {
|
||||||
// Check every 30 seconds
|
// Check every 30 seconds
|
||||||
setInterval(async () => {
|
this.autoUpdateIntervalId = setInterval(async () => {
|
||||||
try {
|
try {
|
||||||
await this.checkForRegistryUpdates();
|
await this.checkForRegistryUpdates();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -692,6 +693,17 @@ export class OneboxServicesManager {
|
|||||||
logger.info('Auto-update monitoring started (30s interval)');
|
logger.info('Auto-update monitoring started (30s interval)');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop auto-update monitoring
|
||||||
|
*/
|
||||||
|
stopAutoUpdateMonitoring(): void {
|
||||||
|
if (this.autoUpdateIntervalId !== null) {
|
||||||
|
clearInterval(this.autoUpdateIntervalId);
|
||||||
|
this.autoUpdateIntervalId = null;
|
||||||
|
logger.debug('Auto-update monitoring stopped');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check all services using onebox registry for updates
|
* Check all services using onebox registry for updates
|
||||||
*/
|
*/
|
||||||
|
|||||||
243
ts/classes/systemd.ts
Normal file
243
ts/classes/systemd.ts
Normal file
@@ -0,0 +1,243 @@
|
|||||||
|
/**
|
||||||
|
* Systemd Service Manager for Onebox
|
||||||
|
*
|
||||||
|
* Handles systemd unit file installation, enabling, starting, stopping,
|
||||||
|
* and status checking. Modeled on nupst's direct systemctl approach —
|
||||||
|
* no external library dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { logger } from '../logging.ts';
|
||||||
|
import { getErrorMessage } from '../utils/error.ts';
|
||||||
|
|
||||||
|
const SERVICE_NAME = 'onebox';
|
||||||
|
const SERVICE_FILE_PATH = '/etc/systemd/system/onebox.service';
|
||||||
|
|
||||||
|
const SERVICE_UNIT_TEMPLATE = `[Unit]
|
||||||
|
Description=Onebox - Self-hosted container platform
|
||||||
|
After=network-online.target docker.service
|
||||||
|
Wants=network-online.target
|
||||||
|
Requires=docker.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/usr/local/bin/onebox systemd start-daemon
|
||||||
|
Restart=always
|
||||||
|
RestartSec=10
|
||||||
|
WorkingDirectory=/var/lib/onebox
|
||||||
|
Environment=PATH=/usr/bin:/usr/local/bin
|
||||||
|
Environment=HOME=/root
|
||||||
|
Environment=DENO_DIR=/root/.cache/deno
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
`;
|
||||||
|
|
||||||
|
export class OneboxSystemd {
|
||||||
|
/**
|
||||||
|
* Install and enable the systemd service
|
||||||
|
*/
|
||||||
|
async enable(): Promise<void> {
|
||||||
|
try {
|
||||||
|
// Ensure Docker is installed before writing unit file (it requires docker.service)
|
||||||
|
await this.ensureDocker();
|
||||||
|
|
||||||
|
// Write the unit file
|
||||||
|
logger.info('Writing systemd unit file...');
|
||||||
|
await Deno.writeTextFile(SERVICE_FILE_PATH, SERVICE_UNIT_TEMPLATE);
|
||||||
|
logger.info(`Unit file written to ${SERVICE_FILE_PATH}`);
|
||||||
|
|
||||||
|
// Reload systemd daemon
|
||||||
|
await this.runSystemctl(['daemon-reload']);
|
||||||
|
|
||||||
|
// Enable the service
|
||||||
|
const result = await this.runSystemctl(['enable', `${SERVICE_NAME}.service`]);
|
||||||
|
if (!result.success) {
|
||||||
|
throw new Error(`Failed to enable service: ${result.stderr}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.success('Onebox systemd service enabled');
|
||||||
|
logger.info('Start with: onebox systemd start');
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(`Failed to enable service: ${getErrorMessage(error)}`);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop, disable, and remove the systemd service
|
||||||
|
*/
|
||||||
|
async disable(): Promise<void> {
|
||||||
|
try {
|
||||||
|
// Stop the service (ignore errors if not running)
|
||||||
|
await this.runSystemctl(['stop', `${SERVICE_NAME}.service`]);
|
||||||
|
|
||||||
|
// Disable the service
|
||||||
|
await this.runSystemctl(['disable', `${SERVICE_NAME}.service`]);
|
||||||
|
|
||||||
|
// Remove the unit file
|
||||||
|
try {
|
||||||
|
await Deno.remove(SERVICE_FILE_PATH);
|
||||||
|
logger.info(`Removed ${SERVICE_FILE_PATH}`);
|
||||||
|
} catch {
|
||||||
|
// File might not exist
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reload systemd daemon
|
||||||
|
await this.runSystemctl(['daemon-reload']);
|
||||||
|
|
||||||
|
logger.success('Onebox systemd service disabled and removed');
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(`Failed to disable service: ${getErrorMessage(error)}`);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the service via systemctl
|
||||||
|
*/
|
||||||
|
async start(): Promise<void> {
|
||||||
|
const result = await this.runSystemctl(['start', `${SERVICE_NAME}.service`]);
|
||||||
|
if (!result.success) {
|
||||||
|
logger.error(`Failed to start service: ${result.stderr}`);
|
||||||
|
throw new Error(`Failed to start onebox service`);
|
||||||
|
}
|
||||||
|
logger.success('Onebox service started');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop the service via systemctl
|
||||||
|
*/
|
||||||
|
async stop(): Promise<void> {
|
||||||
|
const result = await this.runSystemctl(['stop', `${SERVICE_NAME}.service`]);
|
||||||
|
if (!result.success) {
|
||||||
|
logger.error(`Failed to stop service: ${result.stderr}`);
|
||||||
|
throw new Error(`Failed to stop onebox service`);
|
||||||
|
}
|
||||||
|
logger.success('Onebox service stopped');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get and display service status
|
||||||
|
*/
|
||||||
|
async getStatus(): Promise<string> {
|
||||||
|
const result = await this.runSystemctl(['status', `${SERVICE_NAME}.service`]);
|
||||||
|
const output = result.stdout;
|
||||||
|
|
||||||
|
let status: string;
|
||||||
|
if (output.includes('active (running)')) {
|
||||||
|
status = 'running';
|
||||||
|
} else if (output.includes('inactive') || output.includes('dead')) {
|
||||||
|
status = 'stopped';
|
||||||
|
} else if (output.includes('failed')) {
|
||||||
|
status = 'failed';
|
||||||
|
} else if (!result.success && result.stderr.includes('could not be found')) {
|
||||||
|
status = 'not-installed';
|
||||||
|
} else {
|
||||||
|
status = 'unknown';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print the raw systemctl output for full details
|
||||||
|
if (output.trim()) {
|
||||||
|
console.log(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show service logs via journalctl
|
||||||
|
*/
|
||||||
|
async showLogs(): Promise<void> {
|
||||||
|
const cmd = new Deno.Command('journalctl', {
|
||||||
|
args: ['-u', `${SERVICE_NAME}.service`, '-f'],
|
||||||
|
stdout: 'inherit',
|
||||||
|
stderr: 'inherit',
|
||||||
|
});
|
||||||
|
await cmd.output();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the service unit file is installed
|
||||||
|
*/
|
||||||
|
async isInstalled(): Promise<boolean> {
|
||||||
|
try {
|
||||||
|
await Deno.stat(SERVICE_FILE_PATH);
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure Docker is installed, installing it if necessary
|
||||||
|
*/
|
||||||
|
private async ensureDocker(): Promise<void> {
|
||||||
|
try {
|
||||||
|
const cmd = new Deno.Command('docker', {
|
||||||
|
args: ['--version'],
|
||||||
|
stdout: 'piped',
|
||||||
|
stderr: 'piped',
|
||||||
|
});
|
||||||
|
const result = await cmd.output();
|
||||||
|
if (result.success) {
|
||||||
|
const version = new TextDecoder().decode(result.stdout).trim();
|
||||||
|
logger.info(`Docker found: ${version}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// docker command not found
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info('Docker not found. Installing Docker...');
|
||||||
|
const installCmd = new Deno.Command('bash', {
|
||||||
|
args: ['-c', 'curl -fsSL https://get.docker.com | sh'],
|
||||||
|
stdin: 'inherit',
|
||||||
|
stdout: 'inherit',
|
||||||
|
stderr: 'inherit',
|
||||||
|
});
|
||||||
|
const installResult = await installCmd.output();
|
||||||
|
if (!installResult.success) {
|
||||||
|
throw new Error('Failed to install Docker. Please install it manually: curl -fsSL https://get.docker.com | sh');
|
||||||
|
}
|
||||||
|
logger.success('Docker installed successfully');
|
||||||
|
|
||||||
|
// Initialize Docker Swarm
|
||||||
|
logger.info('Initializing Docker Swarm...');
|
||||||
|
const swarmCmd = new Deno.Command('docker', {
|
||||||
|
args: ['swarm', 'init'],
|
||||||
|
stdout: 'piped',
|
||||||
|
stderr: 'piped',
|
||||||
|
});
|
||||||
|
const swarmResult = await swarmCmd.output();
|
||||||
|
if (swarmResult.success) {
|
||||||
|
logger.success('Docker Swarm initialized');
|
||||||
|
} else {
|
||||||
|
const stderr = new TextDecoder().decode(swarmResult.stderr);
|
||||||
|
if (stderr.includes('already part of a swarm')) {
|
||||||
|
logger.info('Docker Swarm already initialized');
|
||||||
|
} else {
|
||||||
|
logger.warn(`Docker Swarm init warning: ${stderr.trim()}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run a systemctl command and return results
|
||||||
|
*/
|
||||||
|
private async runSystemctl(
|
||||||
|
args: string[]
|
||||||
|
): Promise<{ success: boolean; stdout: string; stderr: string }> {
|
||||||
|
const cmd = new Deno.Command('systemctl', {
|
||||||
|
args,
|
||||||
|
stdout: 'piped',
|
||||||
|
stderr: 'piped',
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await cmd.output();
|
||||||
|
return {
|
||||||
|
success: result.success,
|
||||||
|
stdout: new TextDecoder().decode(result.stdout),
|
||||||
|
stderr: new TextDecoder().decode(result.stderr),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
89
ts/cli.ts
89
ts/cli.ts
@@ -7,6 +7,7 @@ import { projectInfo } from './info.ts';
|
|||||||
import { getErrorMessage } from './utils/error.ts';
|
import { getErrorMessage } from './utils/error.ts';
|
||||||
import { Onebox } from './classes/onebox.ts';
|
import { Onebox } from './classes/onebox.ts';
|
||||||
import { OneboxDaemon } from './classes/daemon.ts';
|
import { OneboxDaemon } from './classes/daemon.ts';
|
||||||
|
import { OneboxSystemd } from './classes/systemd.ts';
|
||||||
|
|
||||||
export async function runCli(): Promise<void> {
|
export async function runCli(): Promise<void> {
|
||||||
const args = Deno.args;
|
const args = Deno.args;
|
||||||
@@ -25,6 +26,19 @@ export async function runCli(): Promise<void> {
|
|||||||
const subcommand = args[1];
|
const subcommand = args[1];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// === LIGHTWEIGHT COMMANDS (no init()) ===
|
||||||
|
if (command === 'systemd') {
|
||||||
|
await handleSystemdCommand(subcommand, args.slice(2));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (command === 'upgrade') {
|
||||||
|
await handleUpgradeCommand();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// === HEAVY COMMANDS (require full init()) ===
|
||||||
|
|
||||||
// Server command has special handling (doesn't shut down)
|
// Server command has special handling (doesn't shut down)
|
||||||
if (command === 'server') {
|
if (command === 'server') {
|
||||||
const onebox = new Onebox();
|
const onebox = new Onebox();
|
||||||
@@ -60,10 +74,6 @@ export async function runCli(): Promise<void> {
|
|||||||
await handleNginxCommand(onebox, subcommand, args.slice(2));
|
await handleNginxCommand(onebox, subcommand, args.slice(2));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'daemon':
|
|
||||||
await handleDaemonCommand(onebox, subcommand, args.slice(2));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'config':
|
case 'config':
|
||||||
await handleConfigCommand(onebox, subcommand, args.slice(2));
|
await handleConfigCommand(onebox, subcommand, args.slice(2));
|
||||||
break;
|
break;
|
||||||
@@ -72,10 +82,6 @@ export async function runCli(): Promise<void> {
|
|||||||
await handleStatusCommand(onebox);
|
await handleStatusCommand(onebox);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'upgrade':
|
|
||||||
await handleUpgradeCommand();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
logger.error(`Unknown command: ${command}`);
|
logger.error(`Unknown command: ${command}`);
|
||||||
printHelp();
|
printHelp();
|
||||||
@@ -282,7 +288,7 @@ async function handleServerCommand(onebox: Onebox, args: string[]) {
|
|||||||
await OneboxDaemon.ensureNoDaemon();
|
await OneboxDaemon.ensureNoDaemon();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Cannot start in ephemeral mode: Daemon is already running');
|
logger.error('Cannot start in ephemeral mode: Daemon is already running');
|
||||||
logger.info('Stop the daemon first: onebox daemon stop');
|
logger.info('Stop the daemon first: onebox systemd stop');
|
||||||
logger.info('Or run without --ephemeral to use the existing daemon');
|
logger.info('Or run without --ephemeral to use the existing daemon');
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
@@ -326,39 +332,49 @@ async function handleServerCommand(onebox: Onebox, args: string[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Daemon commands
|
// Systemd service commands (lightweight — no Onebox init)
|
||||||
async function handleDaemonCommand(onebox: Onebox, subcommand: string, _args: string[]) {
|
async function handleSystemdCommand(subcommand: string, _args: string[]) {
|
||||||
|
const systemd = new OneboxSystemd();
|
||||||
|
|
||||||
switch (subcommand) {
|
switch (subcommand) {
|
||||||
case 'install':
|
case 'enable':
|
||||||
await onebox.daemon.installService();
|
await systemd.enable();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'disable':
|
||||||
|
await systemd.disable();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'start':
|
case 'start':
|
||||||
await onebox.startDaemon();
|
await systemd.start();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'stop':
|
case 'stop':
|
||||||
await onebox.stopDaemon();
|
await systemd.stop();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'logs': {
|
case 'status': {
|
||||||
const command = new Deno.Command('journalctl', {
|
const status = await systemd.getStatus();
|
||||||
args: ['-u', 'smartdaemon_onebox', '-f'],
|
logger.info(`Service status: ${status}`);
|
||||||
stdout: 'inherit',
|
|
||||||
stderr: 'inherit',
|
|
||||||
});
|
|
||||||
await command.output();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'status': {
|
case 'logs':
|
||||||
const status = await onebox.daemon.getServiceStatus();
|
await systemd.showLogs();
|
||||||
logger.info(`Daemon status: ${status}`);
|
break;
|
||||||
|
|
||||||
|
case 'start-daemon': {
|
||||||
|
// This is what systemd's ExecStart calls — full init + daemon loop
|
||||||
|
const onebox = new Onebox();
|
||||||
|
await onebox.init();
|
||||||
|
await onebox.daemon.start();
|
||||||
|
// start() blocks (keepAlive loop) until SIGTERM/SIGINT
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
logger.error(`Unknown daemon subcommand: ${subcommand}`);
|
logger.error(`Unknown systemd subcommand: ${subcommand}`);
|
||||||
|
logger.info('Available: enable, disable, start, stop, status, logs');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -506,11 +522,12 @@ Commands:
|
|||||||
nginx test
|
nginx test
|
||||||
nginx status
|
nginx status
|
||||||
|
|
||||||
daemon install
|
systemd enable Install and enable systemd service
|
||||||
daemon start
|
systemd disable Stop, disable, and remove systemd service
|
||||||
daemon stop
|
systemd start Start onebox via systemctl
|
||||||
daemon logs
|
systemd stop Stop onebox via systemctl
|
||||||
daemon status
|
systemd status Show systemd service status
|
||||||
|
systemd logs Follow service logs (journalctl)
|
||||||
|
|
||||||
config show
|
config show
|
||||||
config set <key> <value>
|
config set <key> <value>
|
||||||
@@ -530,15 +547,15 @@ Development Workflow:
|
|||||||
onebox service add ... # In another terminal
|
onebox service add ... # In another terminal
|
||||||
|
|
||||||
Production Workflow:
|
Production Workflow:
|
||||||
onebox daemon install # Install systemd service
|
onebox systemd enable # Install and enable systemd service
|
||||||
onebox daemon start # Start daemon
|
onebox systemd start # Start via systemctl
|
||||||
onebox service add ... # CLI uses daemon
|
onebox service add ... # CLI manages services
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
onebox server --ephemeral # Start dev server
|
onebox server --ephemeral # Start dev server
|
||||||
onebox service add myapp --image nginx:latest --domain app.example.com --port 80
|
onebox service add myapp --image nginx:latest --domain app.example.com --port 80
|
||||||
onebox registry add --url registry.example.com --username user --password pass
|
onebox registry add --url registry.example.com --username user --password pass
|
||||||
onebox daemon install
|
onebox systemd enable
|
||||||
onebox daemon start
|
onebox systemd start
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export { OneboxReverseProxy } from './classes/reverseproxy.ts';
|
|||||||
export { OneboxDnsManager } from './classes/dns.ts';
|
export { OneboxDnsManager } from './classes/dns.ts';
|
||||||
export { OneboxSslManager } from './classes/ssl.ts';
|
export { OneboxSslManager } from './classes/ssl.ts';
|
||||||
export { OneboxDaemon } from './classes/daemon.ts';
|
export { OneboxDaemon } from './classes/daemon.ts';
|
||||||
|
export { OneboxSystemd } from './classes/systemd.ts';
|
||||||
export { OneboxHttpServer } from './classes/httpserver.ts';
|
export { OneboxHttpServer } from './classes/httpserver.ts';
|
||||||
export { OneboxApiClient } from './classes/apiclient.ts';
|
export { OneboxApiClient } from './classes/apiclient.ts';
|
||||||
|
|
||||||
|
|||||||
@@ -165,5 +165,42 @@ export class PlatformHandler {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Get platform service logs
|
||||||
|
this.typedrouter.addTypedHandler(
|
||||||
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetPlatformServiceLogs>(
|
||||||
|
'getPlatformServiceLogs',
|
||||||
|
async (dataArg) => {
|
||||||
|
await requireValidIdentity(this.opsServerRef.adminHandler, dataArg);
|
||||||
|
const service = this.opsServerRef.oneboxRef.database.getPlatformServiceByType(dataArg.serviceType);
|
||||||
|
if (!service || !service.containerId) {
|
||||||
|
throw new plugins.typedrequest.TypedResponseError('Platform service has no container');
|
||||||
|
}
|
||||||
|
|
||||||
|
const tail = dataArg.tail || 100;
|
||||||
|
const rawLogs = await this.opsServerRef.oneboxRef.docker.getContainerLogs(service.containerId, tail);
|
||||||
|
|
||||||
|
// Parse raw log output into structured entries
|
||||||
|
const logLines = (rawLogs.stdout + rawLogs.stderr)
|
||||||
|
.split('\n')
|
||||||
|
.filter((line: string) => line.trim());
|
||||||
|
|
||||||
|
const logs = logLines.map((line: string, index: number) => {
|
||||||
|
const isError = line.toLowerCase().includes('error') || line.toLowerCase().includes('fatal');
|
||||||
|
const isWarn = line.toLowerCase().includes('warn');
|
||||||
|
return {
|
||||||
|
id: index,
|
||||||
|
serviceId: 0,
|
||||||
|
timestamp: Date.now(),
|
||||||
|
message: line,
|
||||||
|
level: (isError ? 'error' : isWarn ? 'warn' : 'info') as 'info' | 'warn' | 'error' | 'debug',
|
||||||
|
source: 'stdout' as const,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return { logs };
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,10 +17,6 @@ export { path, fs, http, encoding };
|
|||||||
import { Database } from '@db/sqlite';
|
import { Database } from '@db/sqlite';
|
||||||
export const sqlite = { DB: Database };
|
export const sqlite = { DB: Database };
|
||||||
|
|
||||||
// Systemd Daemon Integration
|
|
||||||
import * as smartdaemon from '@push.rocks/smartdaemon';
|
|
||||||
export { smartdaemon };
|
|
||||||
|
|
||||||
// Docker API Client
|
// Docker API Client
|
||||||
import { DockerHost } from '@apiclient.xyz/docker';
|
import { DockerHost } from '@apiclient.xyz/docker';
|
||||||
export const docker = { Docker: DockerHost };
|
export const docker = { Docker: DockerHost };
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -69,3 +69,18 @@ export interface IReq_GetPlatformServiceStats extends plugins.typedrequestInterf
|
|||||||
stats: data.IContainerStats;
|
stats: data.IContainerStats;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IReq_GetPlatformServiceLogs extends plugins.typedrequestInterfaces.implementsTR<
|
||||||
|
plugins.typedrequestInterfaces.ITypedRequest,
|
||||||
|
IReq_GetPlatformServiceLogs
|
||||||
|
> {
|
||||||
|
method: 'getPlatformServiceLogs';
|
||||||
|
request: {
|
||||||
|
identity: data.IIdentity;
|
||||||
|
serviceType: data.TPlatformServiceType;
|
||||||
|
tail?: number;
|
||||||
|
};
|
||||||
|
response: {
|
||||||
|
logs: data.ILogEntry[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@serve.zone/onebox',
|
name: '@serve.zone/onebox',
|
||||||
version: '1.13.2',
|
version: '1.18.3',
|
||||||
description: 'Self-hosted container platform with automatic SSL and DNS - a mini Heroku for single servers'
|
description: 'Self-hosted container platform with automatic SSL and DNS - a mini Heroku for single servers'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ export interface IServicesState {
|
|||||||
currentServiceStats: interfaces.data.IContainerStats | null;
|
currentServiceStats: interfaces.data.IContainerStats | null;
|
||||||
platformServices: interfaces.data.IPlatformService[];
|
platformServices: interfaces.data.IPlatformService[];
|
||||||
currentPlatformService: interfaces.data.IPlatformService | null;
|
currentPlatformService: interfaces.data.IPlatformService | null;
|
||||||
|
currentPlatformServiceStats: interfaces.data.IContainerStats | null;
|
||||||
|
currentPlatformServiceLogs: interfaces.data.ILogEntry[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface INetworkState {
|
export interface INetworkState {
|
||||||
@@ -88,6 +90,8 @@ export const servicesStatePart = await appState.getStatePart<IServicesState>(
|
|||||||
currentServiceStats: null,
|
currentServiceStats: null,
|
||||||
platformServices: [],
|
platformServices: [],
|
||||||
currentPlatformService: null,
|
currentPlatformService: null,
|
||||||
|
currentPlatformServiceStats: null,
|
||||||
|
currentPlatformServiceLogs: [],
|
||||||
},
|
},
|
||||||
'soft',
|
'soft',
|
||||||
);
|
);
|
||||||
@@ -476,6 +480,46 @@ export const stopPlatformServiceAction = servicesStatePart.createAction<{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const fetchPlatformServiceStatsAction = servicesStatePart.createAction<{
|
||||||
|
serviceType: interfaces.data.TPlatformServiceType;
|
||||||
|
}>(async (statePartArg, dataArg) => {
|
||||||
|
const context = getActionContext();
|
||||||
|
try {
|
||||||
|
const typedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
||||||
|
interfaces.requests.IReq_GetPlatformServiceStats
|
||||||
|
>('/typedrequest', 'getPlatformServiceStats');
|
||||||
|
const response = await typedRequest.fire({
|
||||||
|
identity: context.identity!,
|
||||||
|
serviceType: dataArg.serviceType,
|
||||||
|
});
|
||||||
|
return { ...statePartArg.getState(), currentPlatformServiceStats: response.stats };
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to fetch platform service stats:', err);
|
||||||
|
return { ...statePartArg.getState(), currentPlatformServiceStats: null };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const fetchPlatformServiceLogsAction = servicesStatePart.createAction<{
|
||||||
|
serviceType: interfaces.data.TPlatformServiceType;
|
||||||
|
tail?: number;
|
||||||
|
}>(async (statePartArg, dataArg) => {
|
||||||
|
const context = getActionContext();
|
||||||
|
try {
|
||||||
|
const typedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
||||||
|
interfaces.requests.IReq_GetPlatformServiceLogs
|
||||||
|
>('/typedrequest', 'getPlatformServiceLogs');
|
||||||
|
const response = await typedRequest.fire({
|
||||||
|
identity: context.identity!,
|
||||||
|
serviceType: dataArg.serviceType,
|
||||||
|
tail: dataArg.tail || 100,
|
||||||
|
});
|
||||||
|
return { ...statePartArg.getState(), currentPlatformServiceLogs: response.logs };
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to fetch platform service logs:', err);
|
||||||
|
return { ...statePartArg.getState(), currentPlatformServiceLogs: [] };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Network Actions
|
// Network Actions
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|||||||
@@ -37,15 +37,15 @@ export class ObAppShell extends DeesElement {
|
|||||||
accessor loginError: string = '';
|
accessor loginError: string = '';
|
||||||
|
|
||||||
private viewTabs = [
|
private viewTabs = [
|
||||||
{ name: 'Dashboard', element: (async () => (await import('./ob-view-dashboard.js')).ObViewDashboard)() },
|
{ name: 'Dashboard', iconName: 'lucide:layoutDashboard', element: (async () => (await import('./ob-view-dashboard.js')).ObViewDashboard)() },
|
||||||
{ name: 'Services', element: (async () => (await import('./ob-view-services.js')).ObViewServices)() },
|
{ name: 'Services', iconName: 'lucide:boxes', element: (async () => (await import('./ob-view-services.js')).ObViewServices)() },
|
||||||
{ name: 'Network', element: (async () => (await import('./ob-view-network.js')).ObViewNetwork)() },
|
{ name: 'Network', iconName: 'lucide:network', element: (async () => (await import('./ob-view-network.js')).ObViewNetwork)() },
|
||||||
{ name: 'Registries', element: (async () => (await import('./ob-view-registries.js')).ObViewRegistries)() },
|
{ name: 'Registries', iconName: 'lucide:package', element: (async () => (await import('./ob-view-registries.js')).ObViewRegistries)() },
|
||||||
{ name: 'Tokens', element: (async () => (await import('./ob-view-tokens.js')).ObViewTokens)() },
|
{ name: 'Tokens', iconName: 'lucide:key', element: (async () => (await import('./ob-view-tokens.js')).ObViewTokens)() },
|
||||||
{ name: 'Settings', element: (async () => (await import('./ob-view-settings.js')).ObViewSettings)() },
|
{ name: 'Settings', iconName: 'lucide:settings', element: (async () => (await import('./ob-view-settings.js')).ObViewSettings)() },
|
||||||
];
|
];
|
||||||
|
|
||||||
private resolvedViewTabs: Array<{ name: string; element: any }> = [];
|
private resolvedViewTabs: Array<{ name: string; iconName?: string; element: any }> = [];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@@ -104,6 +104,7 @@ export class ObAppShell extends DeesElement {
|
|||||||
this.resolvedViewTabs = await Promise.all(
|
this.resolvedViewTabs = await Promise.all(
|
||||||
this.viewTabs.map(async (tab) => ({
|
this.viewTabs.map(async (tab) => ({
|
||||||
name: tab.name,
|
name: tab.name,
|
||||||
|
iconName: tab.iconName,
|
||||||
element: await tab.element,
|
element: await tab.element,
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ export class ObViewDashboard extends DeesElement {
|
|||||||
currentServiceStats: null,
|
currentServiceStats: null,
|
||||||
platformServices: [],
|
platformServices: [],
|
||||||
currentPlatformService: null,
|
currentPlatformService: null,
|
||||||
|
currentPlatformServiceStats: null,
|
||||||
|
currentPlatformServiceLogs: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
@@ -149,6 +151,7 @@ export class ObViewDashboard extends DeesElement {
|
|||||||
],
|
],
|
||||||
}}
|
}}
|
||||||
@action-click=${(e: CustomEvent) => this.handleQuickAction(e)}
|
@action-click=${(e: CustomEvent) => this.handleQuickAction(e)}
|
||||||
|
@service-click=${(e: CustomEvent) => this.handlePlatformServiceClick(e)}
|
||||||
></sz-dashboard-view>
|
></sz-dashboard-view>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -161,4 +164,21 @@ export class ObViewDashboard extends DeesElement {
|
|||||||
appstate.uiStatePart.dispatchAction(appstate.setActiveViewAction, { view: 'network' });
|
appstate.uiStatePart.dispatchAction(appstate.setActiveViewAction, { view: 'network' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private handlePlatformServiceClick(e: CustomEvent) {
|
||||||
|
// Find the platform service type from the click event
|
||||||
|
const name = e.detail?.name;
|
||||||
|
const ps = this.servicesState.platformServices.find(
|
||||||
|
(p) => p.displayName === name,
|
||||||
|
);
|
||||||
|
if (ps) {
|
||||||
|
// Navigate to services tab — the ObViewServices component will pick up the type
|
||||||
|
// Store the selected platform type so the services view can open it
|
||||||
|
appstate.servicesStatePart.setState({
|
||||||
|
...appstate.servicesStatePart.getState(),
|
||||||
|
currentPlatformService: ps,
|
||||||
|
});
|
||||||
|
appstate.uiStatePart.dispatchAction(appstate.setActiveViewAction, { view: 'services' });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ export class ObViewServices extends DeesElement {
|
|||||||
currentServiceStats: null,
|
currentServiceStats: null,
|
||||||
platformServices: [],
|
platformServices: [],
|
||||||
currentPlatformService: null,
|
currentPlatformService: null,
|
||||||
|
currentPlatformServiceStats: null,
|
||||||
|
currentPlatformServiceLogs: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
@@ -145,7 +147,37 @@ export class ObViewServices extends DeesElement {
|
|||||||
public static styles = [
|
public static styles = [
|
||||||
cssManager.defaultStyles,
|
cssManager.defaultStyles,
|
||||||
shared.viewHostCss,
|
shared.viewHostCss,
|
||||||
css``,
|
css`
|
||||||
|
.page-actions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-button {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 10px 20px;
|
||||||
|
background: ${cssManager.bdTheme('#18181b', '#fafafa')};
|
||||||
|
color: ${cssManager.bdTheme('#fafafa', '#18181b')};
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: opacity 200ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-button:hover {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deploy-button svg {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
`,
|
||||||
];
|
];
|
||||||
|
|
||||||
async connectedCallback() {
|
async connectedCallback() {
|
||||||
@@ -154,6 +186,18 @@ export class ObViewServices extends DeesElement {
|
|||||||
appstate.servicesStatePart.dispatchAction(appstate.fetchServicesAction, null),
|
appstate.servicesStatePart.dispatchAction(appstate.fetchServicesAction, null),
|
||||||
appstate.servicesStatePart.dispatchAction(appstate.fetchPlatformServicesAction, null),
|
appstate.servicesStatePart.dispatchAction(appstate.fetchPlatformServicesAction, null),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// If a platform service was selected from the dashboard, navigate to its detail
|
||||||
|
const state = appstate.servicesStatePart.getState();
|
||||||
|
if (state.currentPlatformService) {
|
||||||
|
const type = state.currentPlatformService.type;
|
||||||
|
// Clear the selection so it doesn't persist on next visit
|
||||||
|
appstate.servicesStatePart.setState({
|
||||||
|
...appstate.servicesStatePart.getState(),
|
||||||
|
currentPlatformService: null,
|
||||||
|
});
|
||||||
|
this.navigateToPlatformDetail(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(): TemplateResult {
|
public render(): TemplateResult {
|
||||||
@@ -178,8 +222,23 @@ export class ObViewServices extends DeesElement {
|
|||||||
domain: s.domain || null,
|
domain: s.domain || null,
|
||||||
status: mapStatus(s.status),
|
status: mapStatus(s.status),
|
||||||
}));
|
}));
|
||||||
|
const mappedPlatformServices = this.servicesState.platformServices.map((ps) => ({
|
||||||
|
name: ps.displayName,
|
||||||
|
status: ps.status === 'running' ? `Running` : ps.status,
|
||||||
|
running: ps.status === 'running',
|
||||||
|
type: ps.type,
|
||||||
|
}));
|
||||||
return html`
|
return html`
|
||||||
<ob-sectionheading>Services</ob-sectionheading>
|
<ob-sectionheading>Services</ob-sectionheading>
|
||||||
|
<div class="page-actions">
|
||||||
|
<button class="deploy-button" @click=${() => { this.currentView = 'create'; }}>
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||||
|
<line x1="12" y1="5" x2="12" y2="19"></line>
|
||||||
|
<line x1="5" y1="12" x2="19" y2="12"></line>
|
||||||
|
</svg>
|
||||||
|
Deploy Service
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<sz-services-list-view
|
<sz-services-list-view
|
||||||
.services=${mappedServices}
|
.services=${mappedServices}
|
||||||
@service-click=${(e: CustomEvent) => {
|
@service-click=${(e: CustomEvent) => {
|
||||||
@@ -197,6 +256,20 @@ export class ObViewServices extends DeesElement {
|
|||||||
}}
|
}}
|
||||||
@service-action=${(e: CustomEvent) => this.handleServiceAction(e)}
|
@service-action=${(e: CustomEvent) => this.handleServiceAction(e)}
|
||||||
></sz-services-list-view>
|
></sz-services-list-view>
|
||||||
|
<ob-sectionheading style="margin-top: 32px;">Platform Services</ob-sectionheading>
|
||||||
|
<div style="max-width: 500px;">
|
||||||
|
<sz-platform-services-card
|
||||||
|
.services=${mappedPlatformServices}
|
||||||
|
@service-click=${(e: CustomEvent) => {
|
||||||
|
const type = e.detail.type || this.servicesState.platformServices.find(
|
||||||
|
(ps) => ps.displayName === e.detail.name,
|
||||||
|
)?.type;
|
||||||
|
if (type) {
|
||||||
|
this.navigateToPlatformDetail(type);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
></sz-platform-services-card>
|
||||||
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,8 +279,26 @@ export class ObViewServices extends DeesElement {
|
|||||||
<sz-service-create-view
|
<sz-service-create-view
|
||||||
.registries=${[]}
|
.registries=${[]}
|
||||||
@create-service=${async (e: CustomEvent) => {
|
@create-service=${async (e: CustomEvent) => {
|
||||||
|
const formConfig = e.detail;
|
||||||
|
const serviceConfig: interfaces.data.IServiceCreate = {
|
||||||
|
name: formConfig.name,
|
||||||
|
image: formConfig.image,
|
||||||
|
port: formConfig.ports?.[0]?.containerPort
|
||||||
|
? parseInt(formConfig.ports[0].containerPort, 10)
|
||||||
|
: 80,
|
||||||
|
envVars: formConfig.envVars?.reduce(
|
||||||
|
(acc: Record<string, string>, ev: { key: string; value: string }) => {
|
||||||
|
if (ev.key) acc[ev.key] = ev.value;
|
||||||
|
return acc;
|
||||||
|
},
|
||||||
|
{} as Record<string, string>,
|
||||||
|
),
|
||||||
|
enableMongoDB: formConfig.enableMongoDB || false,
|
||||||
|
enableS3: formConfig.enableS3 || false,
|
||||||
|
enableClickHouse: formConfig.enableClickHouse || false,
|
||||||
|
};
|
||||||
await appstate.servicesStatePart.dispatchAction(appstate.createServiceAction, {
|
await appstate.servicesStatePart.dispatchAction(appstate.createServiceAction, {
|
||||||
config: e.detail,
|
config: serviceConfig,
|
||||||
});
|
});
|
||||||
this.currentView = 'list';
|
this.currentView = 'list';
|
||||||
}}
|
}}
|
||||||
@@ -265,10 +356,29 @@ export class ObViewServices extends DeesElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private navigateToPlatformDetail(type: string): void {
|
||||||
|
this.selectedPlatformType = type;
|
||||||
|
// Fetch stats and logs for this platform service
|
||||||
|
const serviceType = type as interfaces.data.TPlatformServiceType;
|
||||||
|
appstate.servicesStatePart.dispatchAction(appstate.fetchPlatformServiceStatsAction, { serviceType });
|
||||||
|
appstate.servicesStatePart.dispatchAction(appstate.fetchPlatformServiceLogsAction, { serviceType });
|
||||||
|
this.currentView = 'platform-detail';
|
||||||
|
}
|
||||||
|
|
||||||
private renderPlatformDetailView(): TemplateResult {
|
private renderPlatformDetailView(): TemplateResult {
|
||||||
const platformService = this.servicesState.platformServices.find(
|
const platformService = this.servicesState.platformServices.find(
|
||||||
(ps) => ps.type === this.selectedPlatformType,
|
(ps) => ps.type === this.selectedPlatformType,
|
||||||
);
|
);
|
||||||
|
const stats = this.servicesState.currentPlatformServiceStats;
|
||||||
|
const metrics = stats
|
||||||
|
? {
|
||||||
|
cpu: Math.round(stats.cpuPercent),
|
||||||
|
memory: Math.round(stats.memoryPercent),
|
||||||
|
storage: 0,
|
||||||
|
connections: 0,
|
||||||
|
}
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ob-sectionheading>Platform Service</ob-sectionheading>
|
<ob-sectionheading>Platform Service</ob-sectionheading>
|
||||||
<sz-platform-service-detail-view
|
<sz-platform-service-detail-view
|
||||||
@@ -277,22 +387,49 @@ export class ObViewServices extends DeesElement {
|
|||||||
id: platformService.type,
|
id: platformService.type,
|
||||||
name: platformService.displayName,
|
name: platformService.displayName,
|
||||||
type: platformService.type,
|
type: platformService.type,
|
||||||
status: platformService.status,
|
status: platformService.status === 'running'
|
||||||
|
? 'running'
|
||||||
|
: platformService.status === 'failed'
|
||||||
|
? 'error'
|
||||||
|
: 'stopped',
|
||||||
version: '',
|
version: '',
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: 0,
|
port: 0,
|
||||||
config: {},
|
config: {},
|
||||||
|
metrics,
|
||||||
}
|
}
|
||||||
: null}
|
: null}
|
||||||
.logs=${[]}
|
.logs=${this.servicesState.currentPlatformServiceLogs.map((log) => ({
|
||||||
@start=${() => {
|
timestamp: new Date(log.timestamp).toLocaleString(),
|
||||||
appstate.servicesStatePart.dispatchAction(appstate.startPlatformServiceAction, {
|
level: log.level,
|
||||||
serviceType: this.selectedPlatformType as any,
|
message: log.message,
|
||||||
|
}))}
|
||||||
|
@back=${() => {
|
||||||
|
this.currentView = 'list';
|
||||||
|
}}
|
||||||
|
@start=${async () => {
|
||||||
|
await appstate.servicesStatePart.dispatchAction(appstate.startPlatformServiceAction, {
|
||||||
|
serviceType: this.selectedPlatformType as interfaces.data.TPlatformServiceType,
|
||||||
|
});
|
||||||
|
// Refresh stats after starting
|
||||||
|
appstate.servicesStatePart.dispatchAction(appstate.fetchPlatformServiceStatsAction, {
|
||||||
|
serviceType: this.selectedPlatformType as interfaces.data.TPlatformServiceType,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
@stop=${() => {
|
@stop=${async () => {
|
||||||
appstate.servicesStatePart.dispatchAction(appstate.stopPlatformServiceAction, {
|
await appstate.servicesStatePart.dispatchAction(appstate.stopPlatformServiceAction, {
|
||||||
serviceType: this.selectedPlatformType as any,
|
serviceType: this.selectedPlatformType as interfaces.data.TPlatformServiceType,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
@restart=${async () => {
|
||||||
|
await appstate.servicesStatePart.dispatchAction(appstate.stopPlatformServiceAction, {
|
||||||
|
serviceType: this.selectedPlatformType as interfaces.data.TPlatformServiceType,
|
||||||
|
});
|
||||||
|
await appstate.servicesStatePart.dispatchAction(appstate.startPlatformServiceAction, {
|
||||||
|
serviceType: this.selectedPlatformType as interfaces.data.TPlatformServiceType,
|
||||||
|
});
|
||||||
|
appstate.servicesStatePart.dispatchAction(appstate.fetchPlatformServiceStatsAction, {
|
||||||
|
serviceType: this.selectedPlatformType as interfaces.data.TPlatformServiceType,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
></sz-platform-service-detail-view>
|
></sz-platform-service-detail-view>
|
||||||
|
|||||||
Reference in New Issue
Block a user