- Update Qdrant startup command to use screen for better management. - Change health check URL to use the correct port (6336). - Improve Qdrant installation check by directly checking the binary. - Simplify Qdrant version check. - Remove unnecessary imports and unused functions. - Update Qdrant config file with correct HTTP and gRPC ports. - Add symlink creation in /usr/local/bin for improved usability. - Use ~/hero/bin for all platforms to avoid permission issues.
125 lines
2.9 KiB
V
125 lines
2.9 KiB
V
module qdrant
|
|
|
|
import freeflowuniverse.herolib.osal
|
|
import freeflowuniverse.herolib.ui.console
|
|
import freeflowuniverse.herolib.core
|
|
import freeflowuniverse.herolib.core.texttools
|
|
import freeflowuniverse.herolib.osal.zinit
|
|
import freeflowuniverse.herolib.installers.ulist
|
|
import os
|
|
|
|
fn startupcmd() ![]zinit.ZProcessNewArgs {
|
|
mut res := []zinit.ZProcessNewArgs{}
|
|
res << zinit.ZProcessNewArgs{
|
|
name: 'qdrant'
|
|
cmd: 'qdrant --config-path ${os.home_dir()}/hero/var/qdrant/config.yaml'
|
|
startuptype: .screen
|
|
}
|
|
return res
|
|
}
|
|
|
|
fn running() !bool {
|
|
res := os.execute('curl -s http://localhost:6336/healthz')
|
|
if res.exit_code == 0 && res.output.contains('healthz check passed') {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
fn start_pre() ! {
|
|
}
|
|
|
|
fn start_post() ! {
|
|
}
|
|
|
|
fn stop_pre() ! {
|
|
}
|
|
|
|
fn stop_post() ! {
|
|
}
|
|
|
|
//////////////////// following actions are not specific to instance of the object
|
|
|
|
// checks if a certain version or above is installed
|
|
fn installed() !bool {
|
|
// Check if qdrant is in the hero bin directory
|
|
qdrant_path := '${os.home_dir()}/hero/bin/qdrant'
|
|
if !os.exists(qdrant_path) {
|
|
return false
|
|
}
|
|
|
|
// Check the version directly without sourcing profile
|
|
res := os.execute('${qdrant_path} -V')
|
|
if res.exit_code != 0 {
|
|
println('Error to call qdrant: ${res}')
|
|
return false
|
|
}
|
|
|
|
r := res.output.split_into_lines().filter(it.contains('qdrant'))
|
|
if r.len != 1 {
|
|
return error("couldn't parse qdrant version.\n${res.output}")
|
|
}
|
|
|
|
if texttools.version(version) == texttools.version(r[0].all_after('qdrant')) {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// get the Upload List of the files
|
|
fn ulist_get() !ulist.UList {
|
|
return ulist.UList{}
|
|
}
|
|
|
|
// uploads to S3 server if configured
|
|
fn upload() ! {
|
|
// installers.upload(
|
|
// cmdname: 'qdrant'
|
|
// source: '${gitpath}/target/x86_64-unknown-linux-musl/release/qdrant'
|
|
// )!
|
|
}
|
|
|
|
fn install() ! {
|
|
console.print_header('install qdrant')
|
|
mut url := ''
|
|
if core.is_linux_arm()! {
|
|
url = 'https://github.com/qdrant/qdrant/releases/download/v${version}/qdrant-aarch64-unknown-linux-musl.tar.gz'
|
|
} else if core.is_linux_intel()! {
|
|
url = 'https://github.com/qdrant/qdrant/releases/download/v${version}/qdrant-x86_64-unknown-linux-musl.tar.gz'
|
|
} else if core.is_osx_arm()! {
|
|
url = 'https://github.com/qdrant/qdrant/releases/download/v${version}/qdrant-aarch64-apple-darwin.tar.gz'
|
|
} else if core.is_osx_intel()! {
|
|
url = 'https://github.com/qdrant/qdrant/releases/download/v${version}/qdrant-x86_64-apple-darwin.tar.gz'
|
|
} else {
|
|
return error('unsported platform')
|
|
}
|
|
mut dest := osal.download(
|
|
url: url
|
|
minsize_kb: 18000
|
|
expand_dir: '/tmp/qdrant'
|
|
)!
|
|
|
|
mut binpath := dest.file_get('qdrant')!
|
|
osal.cmd_add(
|
|
cmdname: 'qdrant'
|
|
source: binpath.path
|
|
)!
|
|
}
|
|
|
|
fn build() ! {}
|
|
|
|
fn destroy() ! {
|
|
osal.process_kill_recursive(name: 'qdrant')!
|
|
osal.cmd_delete('qdrant')!
|
|
|
|
osal.package_remove('
|
|
qdrant
|
|
')!
|
|
|
|
osal.rm('
|
|
qdrant
|
|
${os.home_dir()}/hero/var/qdrant
|
|
')!
|
|
}
|