You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.9 KiB
47 lines
1.9 KiB
param(
|
|
[string]$HostAddress = "127.0.0.1",
|
|
[int]$Port = 8001
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
function ConvertTo-PlainText([Security.SecureString]$Value) {
|
|
$pointer = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($Value)
|
|
try {
|
|
return [Runtime.InteropServices.Marshal]::PtrToStringBSTR($pointer)
|
|
}
|
|
finally {
|
|
[Runtime.InteropServices.Marshal]::ZeroFreeBSTR($pointer)
|
|
}
|
|
}
|
|
|
|
Write-Host "Cloud API runtime configuration"
|
|
Write-Host "Secrets are used only by this process and are not written to a file."
|
|
|
|
$databasePassword = ConvertTo-PlainText (Read-Host "Cloud MySQL password for user dating" -AsSecureString)
|
|
$ossAccessKeyId = Read-Host "Aliyun OSS AccessKey ID"
|
|
$ossAccessKeySecret = ConvertTo-PlainText (Read-Host "Aliyun OSS AccessKey Secret" -AsSecureString)
|
|
$jwtSecret = ConvertTo-PlainText (Read-Host "JWT signing secret" -AsSecureString)
|
|
|
|
if ([string]::IsNullOrWhiteSpace($databasePassword) -or
|
|
[string]::IsNullOrWhiteSpace($ossAccessKeyId) -or
|
|
[string]::IsNullOrWhiteSpace($ossAccessKeySecret) -or
|
|
[string]::IsNullOrWhiteSpace($jwtSecret)) {
|
|
throw "Database password, OSS credentials and JWT secret are required."
|
|
}
|
|
|
|
# URI-escape the password because production passwords may contain URL-reserved characters.
|
|
$encodedDatabasePassword = [Uri]::EscapeDataString($databasePassword)
|
|
$env:DATABASE_URL = "mysql+pymysql://dating:$encodedDatabasePassword@47.116.134.234:3306/dating_app?charset=utf8mb4"
|
|
$env:JWT_SECRET = $jwtSecret
|
|
$env:DEV_RETURN_CODES = "false"
|
|
$env:OSS_ENABLED = "true"
|
|
$env:OSS_ENDPOINT = "https://oss-cn-shanghai.aliyuncs.com"
|
|
$env:OSS_ACCESS_KEY_ID = $ossAccessKeyId
|
|
$env:OSS_ACCESS_KEY_SECRET = $ossAccessKeySecret
|
|
$env:OSS_BUCKET_NAME = "bs-qinghe"
|
|
$env:OSS_BASE_PREFIX = "melove/"
|
|
$env:OSS_DOMAIN = "https://oss.baskbuddy.com"
|
|
|
|
Write-Host "Starting API with cloud MySQL and Aliyun OSS..."
|
|
python -m uvicorn app.main:app --host $HostAddress --port $Port
|
|
|