feat: update file access error handling and improve script downloads

fix: correct file size retrieval in bitrot verification
chore: remove deprecated run.bat and add run.ps1 script
This commit is contained in:
Damonxue
2025-04-08 17:32:12 +08:00
parent 99b473e229
commit 0ed8a8dd19
8 changed files with 79 additions and 62 deletions

View File

@@ -1,34 +0,0 @@
@echo off
rem filepath: run.bat
if not defined SKIP_BUILD (
cargo build -p rustfs --bins
)
set current_dir=%cd%
if not exist .\target\volume\test mkdir .\target\volume\test
if not defined RUST_LOG (
set RUST_BACKTRACE=1
set RUST_LOG=rustfs=debug,ecstore=debug,s3s=debug,iam=debug
)
rem set RUSTFS_ERASURE_SET_DRIVE_COUNT=5
rem set RUSTFS_STORAGE_CLASS_INLINE_BLOCK=512 KB
rem set RUSTFS_VOLUMES=.\target\volume\test{0...4}
set RUSTFS_VOLUMES=.\target\volume\test
set RUSTFS_ADDRESS=0.0.0.0:9000
set RUSTFS_CONSOLE_ENABLE=true
set RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002
rem set RUSTFS_SERVER_DOMAINS=localhost:9000
rem 具体路径修改为配置文件真实路径obs.example.toml 仅供参考
set RUSTFS_OBS_CONFIG=.\config\obs.example.toml"
if not "%~1"=="" (
set RUSTFS_VOLUMES=%~1
)
cargo run --bin rustfs

51
scripts/run.ps1 Normal file
View File

@@ -0,0 +1,51 @@
# Check if static files need to be downloaded
if (-not (Test-Path .\rustfs\static\index.html)) {
Write-Host "Downloading rustfs-console-latest.zip"
Invoke-WebRequest -Uri "https://dl.rustfs.com/artifacts/console/rustfs-console-latest.zip" -OutFile 'tempfile.zip'
Expand-Archive -Path 'tempfile.zip' -DestinationPath '.\rustfs\static' -Force
Remove-Item tempfile.zip
}
# Check if build should be skipped
if (-not $env:SKIP_BUILD) {
cargo build -p rustfs --bins
}
$current_dir = Get-Location
# Create multiple test directories
$testDirs = @("test0", "test1", "test2", "test3", "test4")
foreach ($dir in $testDirs) {
$path = Join-Path -Path ".\target\volume" -ChildPath $dir
if (-not (Test-Path $path)) {
New-Item -ItemType Directory -Path $path -Force | Out-Null
}
}
# Set environment variables
if (-not $env:RUST_LOG) {
$env:RUST_BACKTRACE = 1
$env:RUST_LOG = "rustfs=debug,ecstore=debug,s3s=debug,iam=debug"
}
# The following environment variables are commented out, uncomment them if needed
# $env:RUSTFS_ERASURE_SET_DRIVE_COUNT = 5
# $env:RUSTFS_STORAGE_CLASS_INLINE_BLOCK = "512 KB"
$env:RUSTFS_VOLUMES = ".\target\volume\test{0...4}"
# $env:RUSTFS_VOLUMES = ".\target\volume\test"
$env:RUSTFS_ADDRESS = "127.0.0.1:9000"
$env:RUSTFS_CONSOLE_ENABLE = "true"
$env:RUSTFS_CONSOLE_ADDRESS = "127.0.0.1:9002"
# $env:RUSTFS_SERVER_DOMAINS = "localhost:9000"
# Change to the actual configuration file path, obs.example.toml is for reference only
$env:RUSTFS_OBS_CONFIG = ".\config\obs.example.toml"
# Check command line arguments
if ($args.Count -gt 0) {
$env:RUSTFS_VOLUMES = $args[0]
}
# Run the program
cargo run --bin rustfs

View File

@@ -39,7 +39,7 @@ fi
if [ ! -f ./rustfs/static/index.html ]; then
echo "Downloading rustfs-console-latest.zip"
# download rustfs-console-latest.zip do not show log
curl -s -L "https://dl.rustfs.com/console/rustfs-console-latest.zip" -o tempfile.zip && unzip -q -o tempfile.zip -d ./rustfs/static && rm tempfile.zip
curl -s -L "https://dl.rustfs.com/artifacts/console/rustfs-console-latest.zip" -o tempfile.zip && unzip -q -o tempfile.zip -d ./rustfs/static && rm tempfile.zip
fi
cargo run --bin rustfs