feat: Improve Qdrant installer and update health check port
- 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.
This commit is contained in:
@@ -4,32 +4,26 @@ import freeflowuniverse.herolib.osal
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core
|
||||
import freeflowuniverse.herolib.core.texttools
|
||||
// import freeflowuniverse.herolib.core.pathlib
|
||||
// import freeflowuniverse.herolib.osal.systemd
|
||||
import freeflowuniverse.herolib.osal.zinit
|
||||
import freeflowuniverse.herolib.installers.ulist
|
||||
// import freeflowuniverse.herolib.installers.lang.golang
|
||||
// import freeflowuniverse.herolib.installers.lang.rust
|
||||
// import freeflowuniverse.herolib.installers.lang.python
|
||||
import freeflowuniverse.herolib.core.httpconnection
|
||||
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'
|
||||
name: 'qdrant'
|
||||
cmd: 'qdrant --config-path ${os.home_dir()}/hero/var/qdrant/config.yaml'
|
||||
startuptype: .screen
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
fn running() !bool {
|
||||
println('running')
|
||||
mut installer := get()!
|
||||
url := 'curl http://localhost:6333'
|
||||
mut conn := httpconnection.new(name: 'qdrant', url: url)!
|
||||
r := conn.get(prefix: 'healthz', debug: false) or { return false }
|
||||
println(r)
|
||||
res := os.execute('curl -s http://localhost:6336/healthz')
|
||||
if res.exit_code == 0 && res.output.contains('healthz check passed') {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -49,15 +43,24 @@ fn stop_post() ! {
|
||||
|
||||
// checks if a certain version or above is installed
|
||||
fn installed() !bool {
|
||||
res := os.execute('${osal.profile_path_source_and()!} qdrant -V')
|
||||
// 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
|
||||
}
|
||||
@@ -104,34 +107,7 @@ fn install() ! {
|
||||
)!
|
||||
}
|
||||
|
||||
fn build() ! {
|
||||
// url := 'https://github.com/threefoldtech/qdrant'
|
||||
|
||||
// make sure we install base on the node
|
||||
// if osal.platform() != .ubuntu {
|
||||
// return error('only support ubuntu for now')
|
||||
// }
|
||||
// golang.install()!
|
||||
|
||||
// console.print_header('build qdrant')
|
||||
|
||||
// gitpath := gittools.get_repo(coderoot: '/tmp/builder', url: url, reset: true, pull: true)!
|
||||
|
||||
// cmd := '
|
||||
// cd ${gitpath}
|
||||
// source ~/.cargo/env
|
||||
// exit 1 #todo
|
||||
// '
|
||||
// osal.execute_stdout(cmd)!
|
||||
//
|
||||
// //now copy to the default bin path
|
||||
// mut binpath := dest.file_get('...')!
|
||||
// adds it to path
|
||||
// osal.cmd_add(
|
||||
// cmdname: 'griddriver2'
|
||||
// source: binpath.path
|
||||
// )!
|
||||
}
|
||||
fn build() ! {}
|
||||
|
||||
fn destroy() ! {
|
||||
osal.process_kill_recursive(name: 'qdrant')!
|
||||
|
||||
@@ -250,12 +250,12 @@ service:
|
||||
host: 0.0.0.0
|
||||
|
||||
# HTTP(S) port to bind the service on
|
||||
http_port: 6333
|
||||
http_port: 6336
|
||||
|
||||
# gRPC port to bind the service on.
|
||||
# If `null` - gRPC is disabled. Default: null
|
||||
# Comment to disable gRPC:
|
||||
grpc_port: 6334
|
||||
grpc_port: 6337
|
||||
|
||||
# Enable CORS headers in REST API.
|
||||
# If enabled, browsers would be allowed to query REST endpoints regardless of query origin.
|
||||
@@ -350,4 +350,4 @@ telemetry_disabled: false
|
||||
# # TTL in seconds to reload certificate from disk, useful for certificate rotations.
|
||||
# # Only works for HTTPS endpoints. Does not support gRPC (and intra-cluster communication).
|
||||
# # If `null` - TTL is disabled.
|
||||
# cert_ttl: 3600
|
||||
# cert_ttl: 3600
|
||||
|
||||
@@ -64,6 +64,17 @@ pub fn cmd_add(args_ CmdAddArgs) ! {
|
||||
|
||||
// lets make sure this path is in profile
|
||||
profile_path_add_remove(paths2add: dest)!
|
||||
|
||||
// Create a symlink in /usr/local/bin if possible (for immediate use without sourcing profile)
|
||||
if core.is_linux()! {
|
||||
usr_local_bin := '/usr/local/bin/${args.cmdname}'
|
||||
if os.exists(usr_local_bin) {
|
||||
os.rm(usr_local_bin) or {}
|
||||
}
|
||||
|
||||
// Try to create symlink, but don't fail if it doesn't work (might need sudo)
|
||||
os.execute('ln -sf ${destpath} ${usr_local_bin}')
|
||||
}
|
||||
}
|
||||
|
||||
pub fn profile_path_add_hero() !string {
|
||||
@@ -74,12 +85,9 @@ pub fn profile_path_add_hero() !string {
|
||||
|
||||
pub fn bin_path() !string {
|
||||
mut dest := ''
|
||||
if core.is_osx()! {
|
||||
dest = '${os.home_dir()}/hero/bin'
|
||||
dir_ensure(dest)!
|
||||
} else {
|
||||
dest = '/usr/local/bin'
|
||||
}
|
||||
// Use ~/hero/bin for all platforms to avoid permission issues
|
||||
dest = '${os.home_dir()}/hero/bin'
|
||||
dir_ensure(dest)!
|
||||
return dest
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user