mirror of
https://github.com/thomiceli/opengist.git
synced 2025-01-08 17:42:40 +00:00
helm tmp
This commit is contained in:
parent
6d76e9c2fb
commit
b0b30cc4e9
3 changed files with 43 additions and 29 deletions
|
@ -10,6 +10,8 @@ data:
|
||||||
{{ tpl (.Values.config | toYaml) . | indent 4 }}
|
{{ tpl (.Values.config | toYaml) . | indent 4 }}
|
||||||
replace_secrets.sh: |
|
replace_secrets.sh: |
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
ls
|
||||||
|
exit 0
|
||||||
set -e
|
set -e
|
||||||
config_file="/tmp/config/config.yml"
|
config_file="/tmp/config/config.yml"
|
||||||
output_file="/config/config.yml"
|
output_file="/config/config.yml"
|
||||||
|
|
|
@ -32,20 +32,6 @@ spec:
|
||||||
{{- toYaml . | nindent 8 }}
|
{{- toYaml . | nindent 8 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
spec:
|
spec:
|
||||||
initContainers:
|
|
||||||
- name: init-config
|
|
||||||
image: busybox
|
|
||||||
command: [ "/bin/sh", "/scripts/replace_secrets.sh" ]
|
|
||||||
volumeMounts:
|
|
||||||
- name: config-template
|
|
||||||
mountPath: /tmp/config
|
|
||||||
- name: secret-config
|
|
||||||
mountPath: /tmp/secrets
|
|
||||||
readOnly: true
|
|
||||||
- name: scripts
|
|
||||||
mountPath: /scripts
|
|
||||||
- name: config
|
|
||||||
mountPath: /config
|
|
||||||
{{- with .Values.imagePullSecrets }}
|
{{- with .Values.imagePullSecrets }}
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
{{- toYaml . | nindent 8 }}
|
{{- toYaml . | nindent 8 }}
|
||||||
|
@ -89,7 +75,7 @@ spec:
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: opengist-data
|
- name: opengist-data
|
||||||
mountPath: /opengist
|
mountPath: /opengist
|
||||||
- name: config
|
- name: config-cm
|
||||||
mountPath: /config.yml
|
mountPath: /config.yml
|
||||||
subPath: config.yml
|
subPath: config.yml
|
||||||
{{- if .Values.extraVolumeMounts }}
|
{{- if .Values.extraVolumeMounts }}
|
||||||
|
@ -103,21 +89,9 @@ spec:
|
||||||
{{- else }}
|
{{- else }}
|
||||||
emptyDir: {}
|
emptyDir: {}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
- name: config
|
- name: config-cm
|
||||||
emptyDir: {}
|
|
||||||
- name: config-template
|
|
||||||
configMap:
|
configMap:
|
||||||
name: {{ include "opengist.fullname" . }}
|
name: {{ include "opengist.fullname" . }}
|
||||||
- name: secret-config
|
|
||||||
secret:
|
|
||||||
secretName: {{ include "opengist.fullname" . }}-secret
|
|
||||||
- name: scripts
|
|
||||||
configMap:
|
|
||||||
name: {{ include "opengist.fullname" . }}
|
|
||||||
items:
|
|
||||||
- key: replace_secrets.sh
|
|
||||||
path: replace_secrets.sh
|
|
||||||
mode: 0755
|
|
||||||
{{- if .Values.volumes }}
|
{{- if .Values.volumes }}
|
||||||
{{- toYaml .Values.volumes | nindent 8 }}
|
{{- toYaml .Values.volumes | nindent 8 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
|
@ -12,8 +12,10 @@ import (
|
||||||
"github.com/thomiceli/opengist/internal/web"
|
"github.com/thomiceli/opengist/internal/web"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
var CmdVersion = cli.Command{
|
var CmdVersion = cli.Command{
|
||||||
|
@ -29,10 +31,30 @@ var CmdStart = cli.Command{
|
||||||
Name: "start",
|
Name: "start",
|
||||||
Usage: "Start Opengist server",
|
Usage: "Start Opengist server",
|
||||||
Action: func(ctx *cli.Context) error {
|
Action: func(ctx *cli.Context) error {
|
||||||
|
stopCtx, stop := signal.NotifyContext(ctx.Context, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
defer stop()
|
||||||
|
|
||||||
Initialize(ctx)
|
Initialize(ctx)
|
||||||
|
|
||||||
|
fmt.Println("OG_DEV:", os.Getenv("OG_DEV"))
|
||||||
|
homeDir := config.GetHomeDir()
|
||||||
|
fmt.Println("Home Directory:", homeDir)
|
||||||
|
sessionPath := path.Join(config.GetHomeDir(), "sessions")
|
||||||
|
fmt.Println("Session Path:", sessionPath)
|
||||||
|
fmt.Println("About to start server")
|
||||||
|
|
||||||
go web.NewServer(os.Getenv("OG_DEV") == "1", path.Join(config.GetHomeDir(), "sessions")).Start()
|
go web.NewServer(os.Getenv("OG_DEV") == "1", path.Join(config.GetHomeDir(), "sessions")).Start()
|
||||||
|
fmt.Println("http server started")
|
||||||
go ssh.Start()
|
go ssh.Start()
|
||||||
select {}
|
fmt.Println("ssh server started")
|
||||||
|
|
||||||
|
fmt.Println("stop")
|
||||||
|
<-stopCtx.Done()
|
||||||
|
fmt.Println("sig")
|
||||||
|
shutdown()
|
||||||
|
fmt.Println("done")
|
||||||
|
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +138,22 @@ func Initialize(ctx *cli.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func shutdown() {
|
||||||
|
log.Info().Msg("Shutting down database...")
|
||||||
|
if err := db.Close(); err != nil {
|
||||||
|
log.Error().Err(err).Msg("Failed to close database")
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Info().Msg("Shutting down index...")
|
||||||
|
if config.C.IndexEnabled {
|
||||||
|
if err := index.Close(); err != nil {
|
||||||
|
log.Error().Err(err).Msg("Failed to close index")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Info().Msg("Shutdown complete")
|
||||||
|
}
|
||||||
|
|
||||||
func createSymlink(homePath string, configPath string) error {
|
func createSymlink(homePath string, configPath string) error {
|
||||||
if err := os.MkdirAll(filepath.Join(homePath, "symlinks"), 0755); err != nil {
|
if err := os.MkdirAll(filepath.Join(homePath, "symlinks"), 0755); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue