feat: Add Qdrant destroy action and improve installation robustness
- Added a `destroy` action to completely remove Qdrant, including its data directory and zinit service. This improves the cleanup process and prevents leftover files. - Improved the `installed` check to be more reliable by directly checking the Qdrant version without relying on sourcing the profile. This avoids potential issues with profile setup. - Added more informative logging messages throughout the process to improve user experience and debugging. - Improved error handling and reporting. - Use zinit to manage qdrant service to ensure proper stop and remove.
This commit is contained in:
@@ -6,3 +6,4 @@ mut db := qdrant_installer.get()!
|
|||||||
|
|
||||||
db.install()!
|
db.install()!
|
||||||
db.start()!
|
db.start()!
|
||||||
|
db.destroy()!
|
||||||
|
|||||||
@@ -12,18 +12,20 @@ fn startupcmd() ![]zinit.ZProcessNewArgs {
|
|||||||
mut res := []zinit.ZProcessNewArgs{}
|
mut res := []zinit.ZProcessNewArgs{}
|
||||||
res << zinit.ZProcessNewArgs{
|
res << zinit.ZProcessNewArgs{
|
||||||
name: 'qdrant'
|
name: 'qdrant'
|
||||||
cmd: 'qdrant --config-path ${os.home_dir()}/hero/var/qdrant/config.yaml'
|
cmd: 'sleep 5 && qdrant --config-path ${os.home_dir()}/hero/var/qdrant/config.yaml'
|
||||||
startuptype: .screen
|
startuptype: .zinit
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
fn running() !bool {
|
fn running() !bool {
|
||||||
|
console.print_header('checking qdrant is running')
|
||||||
res := os.execute('curl -s http://localhost:6336/healthz')
|
res := os.execute('curl -s http://localhost:6336/healthz')
|
||||||
if res.exit_code == 0 && res.output.contains('healthz check passed') {
|
if res.exit_code == 0 && res.output.contains('healthz check passed') {
|
||||||
|
console.print_debug('qdrant is running')
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
console.print_debug('qdrant is not running')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,16 +45,10 @@ fn stop_post() ! {
|
|||||||
|
|
||||||
// checks if a certain version or above is installed
|
// checks if a certain version or above is installed
|
||||||
fn installed() !bool {
|
fn installed() !bool {
|
||||||
// Check if qdrant is in the hero bin directory
|
console.print_header('checking qdrant installation')
|
||||||
qdrant_path := '${os.home_dir()}/hero/bin/qdrant'
|
|
||||||
if !os.exists(qdrant_path) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the version directly without sourcing profile
|
// Check the version directly without sourcing profile
|
||||||
res := os.execute('${qdrant_path} -V')
|
res := os.execute('qdrant -V')
|
||||||
if res.exit_code != 0 {
|
if res.exit_code != 0 {
|
||||||
println('Error to call qdrant: ${res}')
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,6 +58,7 @@ fn installed() !bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if texttools.version(version) == texttools.version(r[0].all_after('qdrant')) {
|
if texttools.version(version) == texttools.version(r[0].all_after('qdrant')) {
|
||||||
|
console.print_debug('qdrant version is ${r[0].all_after('qdrant')}')
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
@@ -110,15 +107,19 @@ fn install() ! {
|
|||||||
fn build() ! {}
|
fn build() ! {}
|
||||||
|
|
||||||
fn destroy() ! {
|
fn destroy() ! {
|
||||||
osal.process_kill_recursive(name: 'qdrant')!
|
console.print_header('removing qdrant')
|
||||||
osal.cmd_delete('qdrant')!
|
osal.rm('${os.home_dir()}/hero/var/qdrant')!
|
||||||
|
osal.rm('${os.home_dir()}/hero/bin/qdrant')!
|
||||||
|
osal.rm('/usr/local/bin/qdrant')!
|
||||||
|
|
||||||
osal.package_remove('
|
mut zinit_factory := zinit.new()!
|
||||||
qdrant
|
if zinit_factory.exists('qdrant') {
|
||||||
')!
|
zinit_factory.stop('qdrant') or {
|
||||||
|
return error('Could not stop qdrant service due to: ${err}')
|
||||||
osal.rm('
|
}
|
||||||
qdrant
|
zinit_factory.delete('qdrant') or {
|
||||||
${os.home_dir()}/hero/var/qdrant
|
return error('Could not delete qdrant service due to: ${err}')
|
||||||
')!
|
}
|
||||||
|
}
|
||||||
|
console.print_header('qdrant removed')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user