v26.10.1 正式版
修复部分问题,优化性能,进一步推进类型系统
This commit is contained in:
1 parent
48eec484b7
commit
8ce4239452
89 files changed
+5808
-884
No files matched your search
+66
-3
@@ -2,7 +2,7 @@
|
||||
set -eu
|
||||
|
||||
# ChuSQL 安装脚本(Linux/macOS):装 cli/web、写全局配置、
|
||||
# 改 PATH、跑 csql-bootstrap 建系统目录、最后拉起服务。
|
||||
# 改 PATH、初始化系统目录,Linux 注册开机启动服务。
|
||||
|
||||
default_repo='TheBadRoger/ChuSQL'
|
||||
|
||||
@@ -42,6 +42,7 @@ usage: ./install.sh [--component web|cli|both] [options]
|
||||
there is no terminal to ask on; shows up in the shell
|
||||
history, so CHUSQL_ADMIN_PASSWORD is safer)
|
||||
--no-start do not start the server after installing
|
||||
--no-service skip Linux systemd registration and boot autostart
|
||||
|
||||
where the files come from:
|
||||
(default) a package next to this script, else the newest GitHub release
|
||||
@@ -71,6 +72,7 @@ root_user='root'
|
||||
keep_package='no'
|
||||
password_arg=''
|
||||
no_start='no'
|
||||
no_service='no'
|
||||
repo="$default_repo"
|
||||
version='latest'
|
||||
url_arg=''
|
||||
@@ -90,6 +92,7 @@ while [ $# -gt 0 ]; do
|
||||
--keep-package) keep_package='yes'; shift ;;
|
||||
--password) password_arg="${2:-}"; shift 2 ;;
|
||||
--no-start) no_start='yes'; shift ;;
|
||||
--no-service) no_service='yes'; shift ;;
|
||||
--url) url_arg="${2:-}"; shift 2 ;;
|
||||
--repo) repo="${2:-}"; shift 2 ;;
|
||||
--version) version="${2:-}"; shift 2 ;;
|
||||
@@ -617,8 +620,23 @@ echo " root user $root_user (password asked above, kept out of settings.toml)"
|
||||
|
||||
# ---- 释放文件 ----
|
||||
# 包是合在一起的(web 和 cli 都在),这里按这次的选择逐个释放:没选的组件不落地
|
||||
service_file="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/chusql-server.service"
|
||||
use_service='no'
|
||||
if [ "$(uname -s)" = 'Linux' ] && [ "$no_service" = 'no' ]; then
|
||||
command -v systemctl >/dev/null 2>&1 || fail 'systemd is required; use --no-service to opt out'
|
||||
command -v loginctl >/dev/null 2>&1 || fail 'loginctl is required for boot autostart'
|
||||
systemctl --user show-environment >/dev/null || fail 'cannot connect to user systemd; run in a login session or use --no-service'
|
||||
loginctl enable-linger "$(id -un)" || fail 'cannot enable boot autostart; run sudo loginctl enable-linger for this OS user and retry'
|
||||
use_service='yes'
|
||||
if [ -f "$service_file" ]; then
|
||||
systemctl --user stop chusql-server.service || fail 'cannot stop the existing service'
|
||||
fi
|
||||
fi
|
||||
step 'Installing files'
|
||||
mkdir -p "$install_dir/bin" "$log_dir" "$data_dir"
|
||||
install_dir=$(CDPATH= cd -- "$install_dir" && pwd)
|
||||
data_dir=$(CDPATH= cd -- "$data_dir" && pwd)
|
||||
log_dir=$(CDPATH= cd -- "$log_dir" && pwd)
|
||||
cp "$pack/bin/chusql-server" "$install_dir/bin/"
|
||||
cp "$pack/bin/csql-bootstrap" "$install_dir/bin/"
|
||||
for lib in "$pack/bin/"libchusql_core_storage.*; do
|
||||
@@ -646,6 +664,8 @@ step 'Writing settings.toml'
|
||||
config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/ChuSQL"
|
||||
config_file="$config_dir/settings.toml"
|
||||
mkdir -p "$config_dir"
|
||||
config_dir=$(CDPATH= cd -- "$config_dir" && pwd)
|
||||
config_file="$config_dir/settings.toml"
|
||||
sed -e "s|@DATA_DIR@|$(printf '%s' "$data_dir" | sed 's/[\&|]/\\&/g')|g" \
|
||||
-e "s|@LOG_DIR@|$(printf '%s' "$log_dir" | sed 's/[\&|]/\\&/g')|g" \
|
||||
"$pack/resources/settings.toml.linux" > "$config_file"
|
||||
@@ -714,7 +734,46 @@ fi
|
||||
# ---- 拉起服务 ----
|
||||
server_bin="$install_dir/bin/chusql-server"
|
||||
server_pid=''
|
||||
if [ "$no_start" = 'yes' ]; then
|
||||
if [ "$use_service" = 'yes' ]; then
|
||||
step 'Registering the systemd service and boot autostart'
|
||||
for service_arg in "$install_dir" "$server_bin" "$config_file" "$root_user"; do
|
||||
case "$service_arg" in
|
||||
*"
|
||||
"*) fail 'service arguments must not contain newlines' ;;
|
||||
esac
|
||||
done
|
||||
mkdir -p "$(dirname "$service_file")"
|
||||
# 转义 systemd 双引号参数与变量符号。
|
||||
unit_quote() {
|
||||
printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g; s/%/%%/g'
|
||||
}
|
||||
cat > "$service_file" <<EOF
|
||||
[Unit]
|
||||
Description=ChuSQL database server
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory="$(unit_quote "$install_dir")"
|
||||
ExecStart=:"$(unit_quote "$server_bin")" --config "$(unit_quote "$config_file")" --user "$(unit_quote "$root_user")"
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
EOF
|
||||
systemctl --user daemon-reload || fail 'cannot reload systemd units'
|
||||
systemctl --user enable chusql-server.service || fail 'cannot enable boot autostart'
|
||||
if [ "$no_start" = 'yes' ]; then
|
||||
note '--no-start: boot autostart enabled; the server was not started'
|
||||
else
|
||||
systemctl --user restart chusql-server.service || fail 'cannot start chusql-server.service'
|
||||
sleep 1
|
||||
systemctl --user is-active --quiet chusql-server.service || fail 'the server stopped; run journalctl --user -u chusql-server.service'
|
||||
note 'server running under systemd'
|
||||
fi
|
||||
elif [ "$no_start" = 'yes' ]; then
|
||||
note '--no-start: the server was not started'
|
||||
else
|
||||
step 'Starting the server'
|
||||
@@ -739,7 +798,11 @@ if [ "$want_cli" = 'yes' ]; then
|
||||
fi
|
||||
echo " start with $start_with"
|
||||
echo " tcp server $server_bin (listens on [server] listen_host/port, defaults 127.0.0.1:7777)"
|
||||
if [ -n "$server_pid" ]; then
|
||||
if [ "$use_service" = 'yes' ]; then
|
||||
echo ' service chusql-server.service (boot autostart enabled)'
|
||||
echo ' manage systemctl --user status|start|stop|restart chusql-server.service'
|
||||
echo ' logs journalctl --user -u chusql-server.service'
|
||||
elif [ -n "$server_pid" ]; then
|
||||
echo " running pid $server_pid (stop it with: kill $server_pid)"
|
||||
else
|
||||
echo " start it $server_bin --config \"$config_file\" --user $root_user"
|
||||
|
||||
+1
-1
@@ -122,7 +122,7 @@ verify_package() {
|
||||
if ! ( cd "$vtmp/pkg" && HOME="$vtmp/home" CHUSQL_ADMIN_PASSWORD='verify-package' \
|
||||
sh install.sh --component "$comp" \
|
||||
--install-dir "$vtmp/opt" --data-dir "$vtmp/data" --user root \
|
||||
--no-start ) \
|
||||
--no-start --no-service ) \
|
||||
>"$vtmp/log" 2>&1; then
|
||||
sed -n '1,120p' "$vtmp/log" >&2
|
||||
rm -rf "$vtmp"
|
||||
|
||||
@@ -94,6 +94,13 @@ if [ "$assume_yes" = 'no' ]; then
|
||||
fi
|
||||
|
||||
step 'Stopping the service'
|
||||
service_file="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/chusql-server.service"
|
||||
if [ "$(uname -s)" = 'Linux' ] && [ -f "$service_file" ]; then
|
||||
command -v systemctl >/dev/null 2>&1 || fail 'systemctl is required to remove the service'
|
||||
systemctl --user disable --now chusql-server.service || fail 'cannot stop and disable chusql-server.service'
|
||||
rm -f "$service_file"
|
||||
systemctl --user daemon-reload || fail 'cannot reload systemd units'
|
||||
fi
|
||||
stop_by_path "$install_dir/bin/chusql-server"
|
||||
stop_by_path "$install_dir/bin/chusql-web"
|
||||
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
param([string]$Root = (Split-Path -Parent $PSScriptRoot))
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
# 统计物理行数并生成 README 统一风格的本地 SVG 徽章。
|
||||
|
||||
# 生成带文字和色块的本地徽章。
|
||||
function Write-Badge([string]$Directory, [string]$Name, [string]$Label, [string]$Value, [string]$Color, [string]$Description) {
|
||||
$leftWidth = [int]($Label.Length * 7 + 24)
|
||||
$rightWidth = [int]($Value.Length * 7 + 24)
|
||||
$width = $leftWidth + $rightWidth
|
||||
$leftCenter = $leftWidth / 2
|
||||
$rightCenter = $leftWidth + $rightWidth / 2
|
||||
$safeLabel = [Security.SecurityElement]::Escape($Label)
|
||||
$safeValue = [Security.SecurityElement]::Escape($Value)
|
||||
$safeDescription = [Security.SecurityElement]::Escape($Description)
|
||||
$svg = @"
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="$width" height="24" viewBox="0 0 $width 24" role="img" aria-label="$safeLabel`: $safeValue">
|
||||
<title>$safeDescription</title>
|
||||
<defs><clipPath id="rounded"><rect width="$width" height="24" rx="5"/></clipPath></defs>
|
||||
<g clip-path="url(#rounded)"><rect width="$width" height="24" fill="#1e293b"/><rect x="$leftWidth" width="$rightWidth" height="24" fill="$Color"/></g>
|
||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,DejaVu Sans,sans-serif" font-size="11"><text x="$leftCenter" y="16">$safeLabel</text><text x="$rightCenter" y="16">$safeValue</text></g>
|
||||
</svg>
|
||||
"@
|
||||
Set-Content -LiteralPath (Join-Path $Directory "$Name.svg") -Value $svg -Encoding utf8
|
||||
}
|
||||
|
||||
Push-Location -LiteralPath $Root
|
||||
try {
|
||||
$paths = @(& git ls-files --cached --others --exclude-standard)
|
||||
if ($LASTEXITCODE -ne 0) { throw 'git ls-files failed' }
|
||||
$lines = 0
|
||||
$files = 0
|
||||
foreach ($path in ($paths | Sort-Object -Unique)) {
|
||||
if ($path -notmatch '\.(hs|rs|js|css|html|ps1|sh)$') { continue }
|
||||
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) { continue }
|
||||
$lines += @(Get-Content -LiteralPath $path).Count
|
||||
$files++
|
||||
}
|
||||
$label = $lines.ToString('N0', [Globalization.CultureInfo]::InvariantCulture)
|
||||
$badgeDir = Join-Path $Root 'docs/badges'
|
||||
[IO.Directory]::CreateDirectory($badgeDir) | Out-Null
|
||||
$revision = & git rev-parse --short HEAD
|
||||
if ($LASTEXITCODE -ne 0) { throw 'git rev-parse failed' }
|
||||
Write-Badge $badgeDir 'lines' 'source lines' $label '#0369a1' 'Physical source lines; includes tests, comments and blank lines.'
|
||||
Write-Badge $badgeDir 'release' 'release' 'browse' '#6d28d9' 'Open GitHub releases to view published versions.'
|
||||
Write-Badge $badgeDir 'commit' 'commit' $revision '#475569' 'Local HEAD snapshot when the badges were generated; open commit history for latest updates.'
|
||||
Write-Badge $badgeDir 'languages' 'languages' 'Haskell + Rust' '#6d28d9' 'ChuSQL implementation languages: Haskell and Rust.'
|
||||
Write-Badge $badgeDir 'build' 'build' 'view status' '#0369a1' 'Open the build workflow for live status; this local badge is a navigation link.'
|
||||
Write-Badge $badgeDir 'tests' 'tests' 'view status' '#0369a1' 'Open the test workflow for live status; this local badge is a navigation link.'
|
||||
Write-Badge $badgeDir 'gate' 'gate' 'manual status' '#b45309' 'Open the owner-triggered gate workflow for status; this local badge is a navigation link.'
|
||||
Write-Output "source_lines=$lines source_files=$files"
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
Reference in new issue
Block a user