diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dc6b01c65..caaa0a28a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,9 +12,10 @@ This project adheres to [Semantic Versioning](http://semver.org/). + A `:/live` endpoint is available for checking if postgrest is running on its port/socket. 200 OK = alive, 503 = dead. + A `:/ready` endpoint is available for checking a correct internal state(the database connection plus the schema cache). 200 OK = ready, 503 = not ready. - #1988, Add the current user to the request log on stdout - @DavidLindbom, @wolfgangwalther - - #1991, Add the ability to run without `db-uri` using libpq's PG environment variables to connect. @wolfgangwalther - - #1769, Add the ability to run without `db-schemas`, defaulting to `db-schemas=public`. @wolfgangwalther - - #1689, Add the ability to run without `db-anon-role` disabling anonymous access. @wolfgangwalther + - #1823, Add the ability to run postgrest without any configuration. @wolfgangwalther + + #1991, Add the ability to run without `db-uri` using libpq's PG environment variables to connect. @wolfgangwalther + + #1769, Add the ability to run without `db-schemas`, defaulting to `db-schemas=public`. @wolfgangwalther + + #1689, Add the ability to run without `db-anon-role` disabling anonymous access. @wolfgangwalther ### Fixed diff --git a/main/Main.hs b/main/Main.hs index d9d39373ac..5d5e18a710 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -2,15 +2,11 @@ module Main (main) where -import qualified Data.Map.Strict as M - import System.IO (BufferMode (..), hSetBuffering) import qualified PostgREST.App as App import qualified PostgREST.CLI as CLI -import PostgREST.Config (readPGRSTEnvironment) - import Protolude #ifndef mingw32_HOST_OS @@ -20,8 +16,7 @@ import qualified PostgREST.Unix as Unix main :: IO () main = do setBuffering - hasPGRSTEnv <- not . M.null <$> readPGRSTEnvironment - opts <- CLI.readCLIShowHelp hasPGRSTEnv + opts <- CLI.readCLIShowHelp CLI.main installSignalHandlers runAppInSocket opts installSignalHandlers :: App.SignalHandlerInstaller diff --git a/src/PostgREST/CLI.hs b/src/PostgREST/CLI.hs index 6f83d1d37b..0a7a9bf00a 100644 --- a/src/PostgREST/CLI.hs +++ b/src/PostgREST/CLI.hs @@ -82,12 +82,12 @@ data Command | CmdDumpSchema -- | Read command line interface options. Also prints help. -readCLIShowHelp :: Bool -> IO CLI -readCLIShowHelp hasEnvironment = +readCLIShowHelp :: IO CLI +readCLIShowHelp = O.customExecParser prefs opts where prefs = O.prefs $ O.showHelpOnError <> O.showHelpOnEmpty - opts = O.info parser $ O.fullDesc <> progDesc <> footer + opts = O.info parser $ O.fullDesc <> progDesc parser = O.helper <*> exampleParser <*> cliParser progDesc = @@ -96,11 +96,6 @@ readCLIShowHelp hasEnvironment = <> BS.unpack prettyVersion <> " / create a REST API to an existing Postgres database" - footer = - O.footer $ - "To run PostgREST, please pass the FILENAME argument" - <> " or set PGRST_ environment variables." - exampleParser = O.infoOption exampleConfigFile $ O.long "example" @@ -111,12 +106,12 @@ readCLIShowHelp hasEnvironment = cliParser = CLI <$> (dumpConfigFlag <|> dumpSchemaFlag) - <*> optionalIf hasEnvironment configFileOption + <*> O.optional configFileOption configFileOption = O.strArgument $ O.metavar "FILENAME" - <> O.help "Path to configuration file (optional with PGRST_ environment variables)" + <> O.help "Path to configuration file" dumpConfigFlag = O.flag CmdRun CmdDumpConfig $ @@ -128,10 +123,6 @@ readCLIShowHelp hasEnvironment = O.long "dump-schema" <> O.help "Dump loaded schema as JSON and exit (for debugging, output structure is unstable)" - optionalIf :: Alternative f => Bool -> f a -> f (Maybe a) - optionalIf True = O.optional - optionalIf False = fmap Just - exampleConfigFile :: [Char] exampleConfigFile = [str|### REQUIRED: diff --git a/test/io/fixtures.yaml b/test/io/fixtures.yaml index 19e957c917..45f71e2455 100644 --- a/test/io/fixtures.yaml +++ b/test/io/fixtures.yaml @@ -10,13 +10,11 @@ cli: args: ['-e'] - name: dump config args: ['--dump-config'] - use_defaultenv: true - name: dump schema args: ['--dump-schema'] use_defaultenv: true -# failures: config files - name: no config - expect: error +# failures: config files - name: non-existant config file expect: error args: ['does_not_exist.conf']