Skip to content

Don't exit with a help message #1092

@jbergstroem

Description

@jbergstroem

Describe the bug
If permify exits in the case of being unable to connect to a database it displays the help page:

$ docker run -it -e PERMIFY_DATABASE_ENGINE=postgres -e PERMIFY_DATABASE_URI="postgres://user:foo@localhost:5432/db" permify/permify:v0.7.7 serve
Unable to find image 'permify/permify:v0.7.7' locally
v0.7.7: Pulling from permify/permify
52756939035b: Pull complete
d29a74154cf2: Pull complete
6e3f60c3d6dd: Pull complete
Digest: sha256:ace2a9e621b838467339dcefbaded56e1850c39a456287b4eef171b5e45bd44f
Status: Downloaded newer image for permify/permify:v0.7.7
┌────────────────────────────────────────────────────────┐
│                    Permify v0.7.7                      │
│          Fine-grained Authorization Service            │
│                                                        │
│    docs: ............... https://docs.permify.co       │
│    github: .. https://github.com/Permify/permify       │
│    blog: ............... https://permify.co/blog       │
│                                                        │
└────────────────────────────────────────────────────────┘
time=2024-02-27T17:48:36.657Z level=INFO msg="🚀 starting permify service..."
time=2024-02-27T17:48:36.657Z level=ERROR msg="Account ID is not set. Please fill in the Account ID for better support. Get your Account ID from https://permify.co/account"
time=2024-02-27T17:49:32.044Z level=ERROR msg="failed to migrate database" error="failed to connect to `host=localhost user=user database=db`: dial error (dial tcp [::1]:5432: connect: cannot assign requested address)"
time=2024-02-27T17:50:29.276Z level=ERROR msg="failed to initialize database" error="failed to connect to `host=localhost user=user database=db`: dial error (dial tcp [::1]:5432: connect: cannot assign requested address)"
Error: failed to connect to `host=localhost user=user database=db`: dial error (dial tcp [::1]:5432: connect: cannot assign requested address)
Usage:
  permify serve [flags]

Flags:
      --account-id string                                 account id
      --authn-enabled                                     enable server authentication
      --authn-method string                               server authentication method
      --authn-oidc-audience string
      --authn-oidc-issuer string                          issuer identifier of the OpenID Connect Provider
      --authn-preshared-keys strings                      preshared key/keys for server authentication
  -c, --config string                                     config file (default is $HOME/.permify.yaml)
      --database-auto-migrate                             auto migrate database tables (default true)
      --database-engine string                            data source. e.g. postgres, memory (default "memory")
      --database-garbage-collection-enabled               use database garbage collection for expired relationships and attributes
      --database-garbage-collection-interval duration     interval for database garbage collection
      --database-garbage-collection-timeout duration      timeout for database garbage collection
      --database-garbage-collection-window duration       window for database garbage collection
      --database-max-connection-idle-time duration        maximum amount of time a connection may be idle
      --database-max-connection-lifetime duration         maximum amount of time a connection may be reused
      --database-max-idle-connections int                 maximum number of idle connections that can be made to the database at any time
      --database-max-open-connections int                 maximum number of parallel connections that can be made to the database at any time
      --database-uri string                               uri of your data source to store relation tuples and schema
      --distributed-address string                        distributed address
      --distributed-enabled                               enable distributed
      --distributed-port string                           distributed port (default "5000")
      --grpc-port string                                  port that GRPC server run on (default "3478")
      --grpc-tls-cert-path string                         GRPC tls certificate path
      --grpc-tls-enabled                                  switch option for GRPC tls server
      --grpc-tls-key-path string                          GRPC tls key path
  -h, --help                                              help for serve
      --http-cors-allowed-headers strings                 CORS allowed headers for http gateway (default [*])
      --http-cors-allowed-origins strings                 CORS allowed origins for http gateway (default [*])
      --http-enabled                                      switch option for HTTP server (default true)
      --http-port string                                  HTTP port address (default "3476")
      --http-tls-cert-path string                         HTTP tls certificate path
      --http-tls-enabled                                  switch option for HTTP tls server
      --http-tls-key-path string                          HTTP tls key path
      --log-level string                                  real time logs of authorization. Permify uses zerolog as a logger (default "info")
      --log-output string                                 logger output valid values json, text
      --meter-enabled                                     switch option for metric (default true)
      --meter-endpoint string                             export uri for metric data (default "telemetry.permify.co")
      --meter-exporter string                             can be; otlp. (integrated metric tools) (default "otlp")
      --meter-insecure                                    use https or http for metric data
      --meter-urlpath string                              allow to set url path for otlp exporter
      --profiler-enabled                                  switch option for profiler
      --profiler-port string                              profiler port address
      --server-rate-limit int                             the maximum number of requests the server should handle per second (default 10000)
      --service-circuit-breaker                           switch option for service circuit breaker
      --service-permission-bulk-limit int                 bulk operations limit (default 100)
      --service-permission-cache-max-cost string          permission service cache max cost (default "10MiB")
      --service-permission-cache-number-of-counters int   permission service cache number of counters (default 10000)
      --service-permission-concurrency-limit int          concurrency limit (default 100)
      --service-schema-cache-max-cost string              schema service cache max cost (default "10MiB")
      --service-schema-cache-number-of-counters int       schema service cache number of counters (default 1000)
      --service-watch-enabled                             switch option for watch service
      --tracer-enabled                                    switch option for tracing
      --tracer-endpoint string                            export uri for tracing data
      --tracer-exporter string                            can be; jaeger, signoz, zipkin or otlp. (integrated tracing tools)
      --tracer-insecure                                   use https or http for tracer data, only used for otlp exporter or signoz
      --tracer-urlpath string                             allow to set url path for otlp exporter

To Reproduce
docker run -it -e PERMIFY_DATABASE_ENGINE=postgres -e PERMIFY_DATABASE_URI="postgres://user:foo@localhost:5432/db" permify/permify:v0.7.7 serve

Expected behavior
I would like it to emit a final log line about giving up from reconnecting and exiting. This is much easier to follow while debugging.

The user is not invoking the command incorrectly, rather passing incorrect options.

Refs: #1062

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions