adding dify installer
This commit is contained in:
@@ -10,43 +10,28 @@ import freeflowuniverse.herolib.installers.ulist
|
|||||||
import freeflowuniverse.herolib.installers.lang.golang
|
import freeflowuniverse.herolib.installers.lang.golang
|
||||||
import freeflowuniverse.herolib.installers.lang.rust
|
import freeflowuniverse.herolib.installers.lang.rust
|
||||||
import freeflowuniverse.herolib.installers.lang.python
|
import freeflowuniverse.herolib.installers.lang.python
|
||||||
|
import freeflowuniverse.herolib.installers.virt.docker as docker_installer
|
||||||
import os
|
import os
|
||||||
|
|
||||||
fn startupcmd() ![]zinit.ZProcessNewArgs {
|
fn startupcmd() ![]zinit.ZProcessNewArgs {
|
||||||
mut installer := get()!
|
mut installer := get()!
|
||||||
mut res := []zinit.ZProcessNewArgs{}
|
mut res := []zinit.ZProcessNewArgs{}
|
||||||
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
|
mut cfg := get()!
|
||||||
// res << zinit.ZProcessNewArgs{
|
cmd := "
|
||||||
// name: 'dify'
|
git clone https://github.com/langgenius/dify.git -b 1.4.0 ${cfg.path}
|
||||||
// cmd: 'dify server'
|
cp ${cfg.path}/docker/.env.example ${cfg.path}/docker/.env
|
||||||
// env: {
|
export COMPOSE_PROJECT_NAME=${cfg.project_name}
|
||||||
// 'HOME': '/root'
|
docker compose -f ${cfg.compose_file} --env-file ${cfg.path}/docker/.env -e SECRET_KEY=${cfg.secret_key} -e INIT_PASSWORD=${cfg.init_password} up -d
|
||||||
// }
|
"
|
||||||
// }
|
|
||||||
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
fn running() !bool {
|
fn running() !bool {
|
||||||
mut installer := get()!
|
mut installer := get()!
|
||||||
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
|
cfg := get()!
|
||||||
// this checks health of dify
|
cmd := "docker compose -f ${cfg.compose_file} ps | grep dify-web"
|
||||||
// curl http://localhost:3333/api/v1/s --oauth2-bearer 1234 works
|
res := os.execute(cmd)
|
||||||
// url:='http://127.0.0.1:${cfg.port}/api/v1'
|
return res.exit_code == 0
|
||||||
// mut conn := httpconnection.new(name: 'dify', url: url)!
|
|
||||||
|
|
||||||
// if cfg.secret.len > 0 {
|
|
||||||
// conn.default_header.add(.authorization, 'Bearer ${cfg.secret}')
|
|
||||||
// }
|
|
||||||
// conn.default_header.add(.content_type, 'application/json')
|
|
||||||
// console.print_debug("curl -X 'GET' '${url}'/tags --oauth2-bearer ${cfg.secret}")
|
|
||||||
// r := conn.get_json_dict(prefix: 'tags', debug: false) or {return false}
|
|
||||||
// println(r)
|
|
||||||
// if true{panic("ssss")}
|
|
||||||
// tags := r['Tags'] or { return false }
|
|
||||||
// console.print_debug(tags)
|
|
||||||
// console.print_debug('dify is answering.')
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start_pre() ! {
|
fn start_pre() ! {
|
||||||
@@ -65,19 +50,16 @@ 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 {
|
||||||
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
|
mut cfg := get()!
|
||||||
// res := os.execute('${osal.profile_path_source_and()!} dify version')
|
mut docker := docker_installer.get()!
|
||||||
// if res.exit_code != 0 {
|
docker.install()!
|
||||||
// return false
|
|
||||||
// }
|
cmd := "docker compose -f ${cfg.compose_file} ps | grep dify-web"
|
||||||
// r := res.output.split_into_lines().filter(it.trim_space().len > 0)
|
result := os.execute(cmd)
|
||||||
// if r.len != 1 {
|
if result.exit_code != 0 {
|
||||||
// return error("couldn't parse dify version.\n${res.output}")
|
return false
|
||||||
// }
|
}
|
||||||
// if texttools.version(version) == texttools.version(r[0]) {
|
return true
|
||||||
// return true
|
|
||||||
// }
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the Upload List of the files
|
// get the Upload List of the files
|
||||||
@@ -96,33 +78,10 @@ fn upload() ! {
|
|||||||
|
|
||||||
fn install() ! {
|
fn install() ! {
|
||||||
console.print_header('install dify')
|
console.print_header('install dify')
|
||||||
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
|
mut docker := docker_installer.get()!
|
||||||
// mut url := ''
|
mut cfg := get()!
|
||||||
// if core.is_linux_arm()! {
|
docker.install()!
|
||||||
// url = 'https://github.com/dify-dev/dify/releases/download/v${version}/dify_${version}_linux_arm64.tar.gz'
|
osal.execute_silent('docker compose -f ${cfg.compose_file} pull')!
|
||||||
// } else if core.is_linux_intel()! {
|
|
||||||
// url = 'https://github.com/dify-dev/dify/releases/download/v${version}/dify_${version}_linux_amd64.tar.gz'
|
|
||||||
// } else if core.is_osx_arm()! {
|
|
||||||
// url = 'https://github.com/dify-dev/dify/releases/download/v${version}/dify_${version}_darwin_arm64.tar.gz'
|
|
||||||
// } else if osal.is_osx_intel()! {
|
|
||||||
// url = 'https://github.com/dify-dev/dify/releases/download/v${version}/dify_${version}_darwin_amd64.tar.gz'
|
|
||||||
// } else {
|
|
||||||
// return error('unsported platform')
|
|
||||||
// }
|
|
||||||
|
|
||||||
// mut dest := osal.download(
|
|
||||||
// url: url
|
|
||||||
// minsize_kb: 9000
|
|
||||||
// expand_dir: '/tmp/dify'
|
|
||||||
// )!
|
|
||||||
|
|
||||||
// //dest.moveup_single_subdir()!
|
|
||||||
|
|
||||||
// mut binpath := dest.file_get('dify')!
|
|
||||||
// osal.cmd_add(
|
|
||||||
// cmdname: 'dify'
|
|
||||||
// source: binpath.path
|
|
||||||
// )!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build() ! {
|
fn build() ! {
|
||||||
@@ -155,33 +114,24 @@ fn build() ! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn destroy() ! {
|
fn destroy() ! {
|
||||||
// mut systemdfactory := systemd.new()!
|
mut cfg := get()!
|
||||||
// systemdfactory.destroy("zinit")!
|
cmd := "docker compose -f ${cfg.compose_file} down"
|
||||||
|
result := os.execute(cmd)
|
||||||
|
if result.exit_code != 0 {
|
||||||
|
return error("dify isn't running: ${result.output}")
|
||||||
|
}
|
||||||
|
|
||||||
// osal.process_kill_recursive(name:'zinit')!
|
mut docker := docker_installer.get()!
|
||||||
// osal.cmd_delete('zinit')!
|
docker.destroy()!
|
||||||
|
|
||||||
// osal.package_remove('
|
mut zinit_factory := zinit.new()!
|
||||||
// podman
|
if zinit_factory.exists('dify') {
|
||||||
// conmon
|
zinit_factory.stop('dify') or {
|
||||||
// buildah
|
return error('Could not stop dify service due to: ${err}')
|
||||||
// skopeo
|
}
|
||||||
// runc
|
zinit_factory.delete('dify') or {
|
||||||
// ')!
|
return error('Could not delete dify service due to: ${err}')
|
||||||
|
}
|
||||||
// //will remove all paths where go/bin is found
|
}
|
||||||
// osal.profile_path_add_remove(paths2delete:"go/bin")!
|
console.print_header('Dify installation removed')
|
||||||
|
|
||||||
// osal.rm("
|
|
||||||
// podman
|
|
||||||
// conmon
|
|
||||||
// buildah
|
|
||||||
// skopeo
|
|
||||||
// runc
|
|
||||||
// /var/lib/containers
|
|
||||||
// /var/lib/podman
|
|
||||||
// /var/lib/buildah
|
|
||||||
// /tmp/podman
|
|
||||||
// /tmp/conmon
|
|
||||||
// ")!
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,113 +0,0 @@
|
|||||||
module dify
|
|
||||||
|
|
||||||
// import freeflowuniverse.herolib.osal
|
|
||||||
// import freeflowuniverse.herolib.ui.console
|
|
||||||
// import freeflowuniverse.herolib.installers.virt.docker as docker_installer
|
|
||||||
// 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 os
|
|
||||||
|
|
||||||
// fn startupcmd() ![]zinit.ZProcessNewArgs {
|
|
||||||
// mut installer := get()!
|
|
||||||
// mut cfg := get()!
|
|
||||||
// println('Just a print statment')
|
|
||||||
// println(cfg)
|
|
||||||
// mut res := []zinit.ZProcessNewArgs{}
|
|
||||||
// // mut path := cfg.path
|
|
||||||
|
|
||||||
// // cmd := '
|
|
||||||
// // git clone https://github.com/langgenius/dify.git -b 1.4.0 ${path}
|
|
||||||
// // cp ${path}/docker/.env.example ${path}/docker/.env
|
|
||||||
// // export COMPOSE_PROJECT_NAME=${cfg.project_name}
|
|
||||||
// // docker compose -f ${cfg.compose_file} --env-file ${cfg.path}/docker/.env up -d
|
|
||||||
// // '
|
|
||||||
// return res
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fn running() !bool {
|
|
||||||
// cfg := get()!
|
|
||||||
// // cmd := 'docker compose -f ${cfg.compose_file} ps | grep dify-web'
|
|
||||||
// // result := os.execute(cmd)
|
|
||||||
|
|
||||||
// // if result.exit_code != 0 {
|
|
||||||
// // return false
|
|
||||||
// // }
|
|
||||||
// return true
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fn start_pre() ! {
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fn start_post() ! {
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fn stop_pre() ! {
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fn stop_post() ! {
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //////////////////// following actions are not specific to instance of the object
|
|
||||||
|
|
||||||
// fn installed() !bool {
|
|
||||||
// mut cfg := get()!
|
|
||||||
// mut docker := docker_installer.get()!
|
|
||||||
// docker.install()!
|
|
||||||
|
|
||||||
// // cmd := 'docker compose -f ${cfg.compose_file} ps | grep dify-web'
|
|
||||||
// // result := os.execute(cmd)
|
|
||||||
|
|
||||||
// // if result.exit_code != 0 {
|
|
||||||
// // return false
|
|
||||||
// // }
|
|
||||||
// return true
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // get the Upload List of the files
|
|
||||||
// fn ulist_get() !ulist.UList {
|
|
||||||
// // optionally build a UList which is all paths which are result of building, is then used e.g. in upload
|
|
||||||
// return ulist.UList{}
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // uploads to S3 server if configured
|
|
||||||
// fn upload() ! {
|
|
||||||
// // installers.upload(
|
|
||||||
// // cmdname: 'dify'
|
|
||||||
// // source: '${gitpath}/target/x86_64-unknown-linux-musl/release/dify'
|
|
||||||
// // )!
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fn install() ! {
|
|
||||||
// console.print_header('install dify')
|
|
||||||
// mut cfg := get()!
|
|
||||||
// mut docker := docker_installer.get()!
|
|
||||||
// docker.install()!
|
|
||||||
// // os.system('sed -i "s/^SECRET_KEY=.*/SECRET_KEY=${cfg.secret_key}/; s/^INIT_PASSWORD=.*/INIT_PASSWORD=${cfg.init_password}/" ${cfg.path}/docker/.env')
|
|
||||||
// // osal.execute_silent('docker compose pull -f ${cfg.compose_file} pull')!
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fn destroy() ! {
|
|
||||||
// mut cfg := get()!
|
|
||||||
// // cmd := 'docker compose -f ${cfg.compose_file} down'
|
|
||||||
// // result := os.execute(cmd)
|
|
||||||
|
|
||||||
// // if result.exit_code != 0 {
|
|
||||||
// // return error("dify isn't running: ${result.output}")
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// // Remove docker
|
|
||||||
// // mut docker := docker_installer.get()!
|
|
||||||
// // docker.destroy()!
|
|
||||||
|
|
||||||
// // mut zinit_factory := zinit.new()!
|
|
||||||
// // if zinit_factory.exists('dify') {
|
|
||||||
// // zinit_factory.stop('dify') or { return error('Could not stop dify service due to: ${err}') }
|
|
||||||
// // zinit_factory.delete('dify') or {
|
|
||||||
// // return error('Could not delete dify service due to: ${err}')
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
// console.print_header('Dify installation removed')
|
|
||||||
// }
|
|
||||||
@@ -1,279 +0,0 @@
|
|||||||
module dify
|
|
||||||
|
|
||||||
// import freeflowuniverse.herolib.core.base
|
|
||||||
// import freeflowuniverse.herolib.core.playbook
|
|
||||||
// import freeflowuniverse.herolib.ui.console
|
|
||||||
// import freeflowuniverse.herolib.osal.startupmanager
|
|
||||||
// import freeflowuniverse.herolib.osal.zinit
|
|
||||||
// import time
|
|
||||||
|
|
||||||
// __global (
|
|
||||||
// dify_global map[string]&Dify
|
|
||||||
// dify_default string
|
|
||||||
// )
|
|
||||||
|
|
||||||
// /////////FACTORY
|
|
||||||
|
|
||||||
// @[params]
|
|
||||||
// pub struct ArgsGet {
|
|
||||||
// pub mut:
|
|
||||||
// name string
|
|
||||||
// }
|
|
||||||
|
|
||||||
// fn args_get(args_ ArgsGet) ArgsGet {
|
|
||||||
// mut args := args_
|
|
||||||
// if args.name == '' {
|
|
||||||
// args.name = 'default'
|
|
||||||
// }
|
|
||||||
// return args
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pub fn get(args_ ArgsGet) !&Dify {
|
|
||||||
// mut context := base.context()!
|
|
||||||
// mut args := args_get(args_)
|
|
||||||
// mut obj := Dify{}
|
|
||||||
// if args.name !in dify_global {
|
|
||||||
// if !exists(args)! {
|
|
||||||
// set(obj)!
|
|
||||||
// } else {
|
|
||||||
// heroscript := context.hero_config_get('dify', args.name)!
|
|
||||||
// mut obj_ := heroscript_loads(heroscript)!
|
|
||||||
// set_in_mem(obj_)!
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return dify_global[args.name] or {
|
|
||||||
// println(dify_global)
|
|
||||||
// // bug if we get here because should be in globals
|
|
||||||
// panic('could not get config for dify with name, is bug:${args.name}')
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // register the config for the future
|
|
||||||
// pub fn set(o Dify) ! {
|
|
||||||
// set_in_mem(o)!
|
|
||||||
// mut context := base.context()!
|
|
||||||
// heroscript := heroscript_dumps(o)!
|
|
||||||
// context.hero_config_set('dify', o.name, heroscript)!
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // does the config exists?
|
|
||||||
// pub fn exists(args_ ArgsGet) !bool {
|
|
||||||
// mut context := base.context()!
|
|
||||||
// mut args := args_get(args_)
|
|
||||||
// return context.hero_config_exists('dify', args.name)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pub fn delete(args_ ArgsGet) ! {
|
|
||||||
// mut args := args_get(args_)
|
|
||||||
// mut context := base.context()!
|
|
||||||
// context.hero_config_delete('dify', args.name)!
|
|
||||||
// if args.name in dify_global {
|
|
||||||
// // del dify_global[args.name]
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // only sets in mem, does not set as config
|
|
||||||
// fn set_in_mem(o Dify) ! {
|
|
||||||
// mut o2 := obj_init(o)!
|
|
||||||
// dify_global[o.name] = &o2
|
|
||||||
// dify_default = o.name
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @[params]
|
|
||||||
// pub struct PlayArgs {
|
|
||||||
// pub mut:
|
|
||||||
// heroscript string // if filled in then plbook will be made out of it
|
|
||||||
// plbook ?playbook.PlayBook
|
|
||||||
// reset bool
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pub fn play(args_ PlayArgs) ! {
|
|
||||||
// mut args := args_
|
|
||||||
|
|
||||||
// mut plbook := args.plbook or { playbook.new(text: args.heroscript)! }
|
|
||||||
|
|
||||||
// mut install_actions := plbook.find(filter: 'dify.configure')!
|
|
||||||
// if install_actions.len > 0 {
|
|
||||||
// for install_action in install_actions {
|
|
||||||
// heroscript := install_action.heroscript()
|
|
||||||
// mut obj2 := heroscript_loads(heroscript)!
|
|
||||||
// set(obj2)!
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// mut other_actions := plbook.find(filter: 'dify.')!
|
|
||||||
// for other_action in other_actions {
|
|
||||||
// if other_action.name in ['destroy', 'install', 'build'] {
|
|
||||||
// mut p := other_action.params
|
|
||||||
// reset := p.get_default_false('reset')
|
|
||||||
// if other_action.name == 'destroy' || reset {
|
|
||||||
// console.print_debug('install action dify.destroy')
|
|
||||||
// destroy()!
|
|
||||||
// }
|
|
||||||
// if other_action.name == 'install' {
|
|
||||||
// console.print_debug('install action dify.install')
|
|
||||||
// install()!
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if other_action.name in ['start', 'stop', 'restart'] {
|
|
||||||
// mut p := other_action.params
|
|
||||||
// name := p.get('name')!
|
|
||||||
// mut dify_obj := get(name: name)!
|
|
||||||
// console.print_debug('action object:\n${dify_obj}')
|
|
||||||
// if other_action.name == 'start' {
|
|
||||||
// console.print_debug('install action dify.${other_action.name}')
|
|
||||||
// dify_obj.start()!
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if other_action.name == 'stop' {
|
|
||||||
// console.print_debug('install action dify.${other_action.name}')
|
|
||||||
// dify_obj.stop()!
|
|
||||||
// }
|
|
||||||
// if other_action.name == 'restart' {
|
|
||||||
// console.print_debug('install action dify.${other_action.name}')
|
|
||||||
// dify_obj.restart()!
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// //////////////////////////# LIVE CYCLE MANAGEMENT FOR INSTALLERS ///////////////////////////////////
|
|
||||||
// ////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// fn startupmanager_get(cat zinit.StartupManagerType) !startupmanager.StartupManager {
|
|
||||||
// // unknown
|
|
||||||
// // screen
|
|
||||||
// // zinit
|
|
||||||
// // tmux
|
|
||||||
// // systemd
|
|
||||||
// match cat {
|
|
||||||
// .zinit {
|
|
||||||
// console.print_debug('startupmanager: zinit')
|
|
||||||
// return startupmanager.get(cat: .zinit)!
|
|
||||||
// }
|
|
||||||
// .systemd {
|
|
||||||
// console.print_debug('startupmanager: systemd')
|
|
||||||
// return startupmanager.get(cat: .systemd)!
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// console.print_debug('startupmanager: auto')
|
|
||||||
// return startupmanager.get()!
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // load from disk and make sure is properly intialized
|
|
||||||
// pub fn (mut self Dify) reload() ! {
|
|
||||||
// switch(self.name)
|
|
||||||
// self = obj_init(self)!
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pub fn (mut self Dify) start() ! {
|
|
||||||
// switch(self.name)
|
|
||||||
// if self.running()! {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
// console.print_header('dify start')
|
|
||||||
|
|
||||||
// if !installed()! {
|
|
||||||
// install()!
|
|
||||||
// }
|
|
||||||
|
|
||||||
// configure()!
|
|
||||||
|
|
||||||
// start_pre()!
|
|
||||||
|
|
||||||
// for zprocess in startupcmd()! {
|
|
||||||
// mut sm := startupmanager_get(zprocess.startuptype)!
|
|
||||||
|
|
||||||
// console.print_debug('starting dify with ${zprocess.startuptype}...')
|
|
||||||
|
|
||||||
// sm.new(zprocess)!
|
|
||||||
|
|
||||||
// sm.start(zprocess.name)!
|
|
||||||
// }
|
|
||||||
|
|
||||||
// start_post()!
|
|
||||||
|
|
||||||
// for _ in 0 .. 50 {
|
|
||||||
// if self.running()! {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// time.sleep(100 * time.millisecond)
|
|
||||||
// }
|
|
||||||
// return error('dify did not install properly.')
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pub fn (mut self Dify) install_start(args InstallArgs) ! {
|
|
||||||
// switch(self.name)
|
|
||||||
// self.install(args)!
|
|
||||||
// self.start()!
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pub fn (mut self Dify) stop() ! {
|
|
||||||
// switch(self.name)
|
|
||||||
// stop_pre()!
|
|
||||||
// for zprocess in startupcmd()! {
|
|
||||||
// mut sm := startupmanager_get(zprocess.startuptype)!
|
|
||||||
// sm.stop(zprocess.name)!
|
|
||||||
// }
|
|
||||||
// stop_post()!
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pub fn (mut self Dify) restart() ! {
|
|
||||||
// switch(self.name)
|
|
||||||
// self.stop()!
|
|
||||||
// self.start()!
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pub fn (mut self Dify) running() !bool {
|
|
||||||
// switch(self.name)
|
|
||||||
|
|
||||||
// // walk over the generic processes, if not running return
|
|
||||||
// for zprocess in startupcmd()! {
|
|
||||||
// mut sm := startupmanager_get(zprocess.startuptype)!
|
|
||||||
// r := sm.running(zprocess.name)!
|
|
||||||
// if r == false {
|
|
||||||
// return false
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return running()!
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @[params]
|
|
||||||
// pub struct InstallArgs {
|
|
||||||
// pub mut:
|
|
||||||
// reset bool
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pub fn (mut self Dify) install(args InstallArgs) ! {
|
|
||||||
// switch(self.name)
|
|
||||||
// if args.reset || (!installed()!) {
|
|
||||||
// install()!
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pub fn (mut self Dify) build() ! {
|
|
||||||
// switch(self.name)
|
|
||||||
// build()!
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pub fn (mut self Dify) destroy() ! {
|
|
||||||
// switch(self.name)
|
|
||||||
// self.stop() or {}
|
|
||||||
// destroy()!
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // switch instance to be used for dify
|
|
||||||
// pub fn switch(name string) {
|
|
||||||
// dify_default = name
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // helpers
|
|
||||||
|
|
||||||
// @[params]
|
|
||||||
// pub struct DefaultConfigArgs {
|
|
||||||
// instance string = 'default'
|
|
||||||
// }
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
module dify
|
|
||||||
|
|
||||||
// import freeflowuniverse.herolib.data.paramsparser
|
|
||||||
// import freeflowuniverse.herolib.data.encoderhero
|
|
||||||
// import os
|
|
||||||
// import rand
|
|
||||||
|
|
||||||
// pub const version = '0.0.0'
|
|
||||||
// const singleton = true
|
|
||||||
// const default = true
|
|
||||||
|
|
||||||
// @[heap]
|
|
||||||
// pub struct Dify {
|
|
||||||
// pub mut:
|
|
||||||
// path string = '/opt/dify'
|
|
||||||
// init_password string
|
|
||||||
// secret_key string
|
|
||||||
// project_name string = 'dify'
|
|
||||||
// compose_file string = '/opt/dify/docker/docker-compose.yaml'
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // your checking & initialization code if needed
|
|
||||||
// fn obj_init(mycfg_ dify) !dify {
|
|
||||||
// mut mycfg := mycfg_
|
|
||||||
// if mycfg.path == '' {
|
|
||||||
// mycfg.path = '/opt/dify'
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if mycfg.secret_key == '' {
|
|
||||||
// mycfg.secret_key = rand.hex(42)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if mycfg.init_password == '' {
|
|
||||||
// mycfg.init_password = 'slfjbv9NaflKsgjv'
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if mycfg.project_name == '' {
|
|
||||||
// mycfg.project_name = 'dify'
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if mycfg.compose_file == '' {
|
|
||||||
// mycfg.compose_file = '/opt/dify/docker/docker-compose.yaml'
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return mycfg
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // called before start if done
|
|
||||||
// fn configure() ! {
|
|
||||||
// // mut installer := get()!
|
|
||||||
// // mut mycode := $tmpl('templates/atemplate.yaml')
|
|
||||||
// // mut path := pathlib.get_file(path: cfg.configpath, create: true)!
|
|
||||||
// // path.write(mycode)!
|
|
||||||
// // console.print_debug(mycode)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /////////////NORMALLY NO NEED TO TOUCH
|
|
||||||
|
|
||||||
// pub fn heroscript_dumps(obj dify) !string {
|
|
||||||
// return freeflowuniverse.herolib.data.encoderhero.encode[dify](obj)!
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pub fn heroscript_loads(heroscript string) !dify {
|
|
||||||
// mut obj := freeflowuniverse.herolib.data.encoderhero.decode[dify](heroscript)!
|
|
||||||
// return obj
|
|
||||||
// }
|
|
||||||
Reference in New Issue
Block a user