Commit dce71315 authored by Artyom Kartasov's avatar Artyom Kartasov
Browse files

Merge branch 'akartasov_DBLAB-17_delete-idle-clones' into 'master'

feat: automated deletion of idle clones (#17)

See merge request !22
parents 853cec75 a75e7cfa
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -92,10 +92,11 @@ issues:
        - gocyclo
        - lll
        - errcheck
        - wsl
        - gomnd

  exclude-use-default: false
  max-issues-per-linter: 0
  max-same-issues: 0

  new-from-rev: e81dddafc468ececbd995e6d6515f1b20fa09ca0
  new-from-rev: 67c2feac
+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ be needed for further configuration (`initialSnapshot` option in
## Run
Deploy a Database Lab instance in your infrastructure. You would need to:
1. Create `configs/config.yml` (see example in `configs/`).
1. Ensure that the current user has `sudo` privileges to create directories at `mountDir` (check this option in `configs/config.yml`).
1. Build `make all` and launch Database Lab with some token for REST API
authorization `./bin/dblab-server -v some-token`
(or, with log: `./bin/dblab-server -v some-token 2>&1 | tee -a dblab.log`).
+7 −4
Original line number Diff line number Diff line
@@ -15,14 +15,14 @@ import (
	"bytes"
	"context"

	"github.com/jessevdk/go-flags"
	"github.com/pkg/errors"

	"gitlab.com/postgres-ai/database-lab/pkg/config"
	"gitlab.com/postgres-ai/database-lab/pkg/log"
	"gitlab.com/postgres-ai/database-lab/pkg/services/cloning"
	"gitlab.com/postgres-ai/database-lab/pkg/services/provision"
	"gitlab.com/postgres-ai/database-lab/pkg/srv"

	"github.com/jessevdk/go-flags"
	"github.com/pkg/errors"
)

var opts struct {
@@ -67,7 +67,10 @@ func main() {
		log.Fatalf(errors.WithMessage(err, "failed to init a new cloning service"))
	}

	if err = cloningSvc.Run(); err != nil {
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	if err = cloningSvc.Run(ctx); err != nil {
		log.Fatalf(err)
	}

+1 −2
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ provision:
cloning:
  mode: "base"
  accessHost: "localhost"
  autoDelete: true
  idleTime: 120
  idleTime: 0 # Minutes. 0 - means disable automatic deletion.

debug: true
+7 −2
Original line number Diff line number Diff line
@@ -11,15 +11,20 @@
#ssl_cert_file
#ssl_key_file
#ssl
#logging_collector
#log_directory

listen_addresses = '*'

logging_collector = on
log_destination = 'stderr'
log_directory = 'pg_log'
log_line_prefix = '%m [%p]: [%l-1] db=%d,user=%u (%a,%h) '
log_connections = on

## Theoretical number of clones cannot exceed RAM / shared_buffers.
## If you want to have more clones use a lower value.
shared_buffers = '1GB'

# detect idle clones
log_min_duration_statement = 0
log_statement = 'none'
log_timezone = 'Etc/UTC'
Loading