3
0

Fix "disconnect" on SQLite (data lose)

This commit is contained in:
Denis Arh
2022-02-16 16:58:06 +01:00
parent 6ee6607c64
commit 23c7f357fb
3 changed files with 19 additions and 4 deletions

View File

@@ -1,5 +1,14 @@
# build stage
FROM golang:1.17-buster as build-stage
# bundle web-console
FROM node:16.14-alpine as webconsole-build-stage
WORKDIR /webconsole
COPY ./webconsole ./
# Snapshot is built in development mode and with source map
RUN yarn install && yarn build --mode dev --sourcemap
# build server
FROM golang:1.17-buster as server-build-stage
ENV BUILD_OS=linux
ENV BUILD_ARCH=amd64
@@ -9,6 +18,7 @@ WORKDIR /corteza
COPY . ./
COPY --from=webconsole-build-stage /webconsole/dist ./webconsole/dist
RUN make release-clean release
@@ -30,7 +40,7 @@ WORKDIR /corteza
VOLUME /data
COPY --from=build-stage /corteza/build/pkg/corteza-server ./
COPY --from=server-build-stage /corteza/build/pkg/corteza-server ./
HEALTHCHECK --interval=30s --start-period=1m --timeout=30s --retries=3 \
CMD curl --silent --fail --fail-early http://127.0.0.1:80/healthcheck || exit 1

View File

@@ -77,7 +77,7 @@ func (app *CortezaApp) Setup() (err error) {
if app.Opt.DB.IsSQLite() {
log.Warn("You're using SQLite as a storage backend")
log.Warn("Should be used only for testing")
log.Warn("You may experience unstability and data loss")
log.Warn("You may experience instability and data loss")
}
if _, is := os.LookupEnv("MINIO_BUCKET_SEP"); is {

View File

@@ -50,6 +50,11 @@ func Connect(ctx context.Context, dsn string) (store.Storer, error) {
cfg.ASTFormatter = sqlASTFormatter
cfg.CastModuleFieldToColumnType = fieldToColumnTypeCaster
// Set to zero
// Otherwise SQLite (in-memory) disconnects
// and all tables and data is lost
cfg.ConnMaxLifetime = 0
if s.Store, err = rdbms.Connect(ctx, cfg); err != nil {
return nil, err
}