[cli] remove gargantext-server, replace by gargantext-cli server

parent eec85c9f
Pipeline #7055 failed with stages
in 12 minutes and 33 seconds
......@@ -115,7 +115,7 @@ From inside the `haskell-gargantext/` directory, run
### Multi-User with Graphical User Interface (Server Mode)
``` shell
$ ~/.local/bin/stack --docker exec gargantext-server -- --run Prod
$ ~/.local/bin/stack --docker exec gargantext-cli -- server start -m Prod
```
Then you can log in with `user1` / `1resu`
......
......@@ -16,6 +16,7 @@ module CLI.Types where
import Data.String
import Data.Text (Text)
import Gargantext.API.Admin.EnvTypes (Mode)
import Gargantext.Core.Config.Types (SettingsFile(..))
import Gargantext.Core.Types (NodeId)
import Gargantext.Core.Types.Query
......@@ -93,6 +94,17 @@ data CLIRoutes
| CLIR_export FilePath
deriving (Show, Eq)
data CLIServer
= CLIS_start ServerArgs
| CLIS_version
deriving (Show, Eq)
data ServerArgs = ServerArgs
{ server_mode :: !Mode
, server_port :: !Int
, server_toml :: !SettingsFile }
deriving (Show, Eq)
data CLIWorker
= CLIW_run WorkerArgs
| CLIW_runAll WorkerAllArgs
......@@ -127,6 +139,7 @@ data CLICmd
| CCMD_upgrade !UpgradeArgs
| CCMD_golden_file_diff !GoldenFileDiffArgs
| CCMD_routes !CLIRoutes
| CCMD_server !CLIServer
| CCMD_worker !CLIWorker
deriving (Show, Eq)
......
......@@ -32,9 +32,8 @@ import Options.Applicative
import Prelude qualified
-- TODO Command to spawn all workers at once
-- TODO Command to monitor queues
-- TODO Support for KillWorkerSafely on Ctrl-C (so that the job in progress is moved back into the queue)
workerCLI :: CLIWorker -> IO ()
workerCLI (CLIW_run (WorkerArgs { .. })) = do
......
......@@ -11,29 +11,31 @@ Main specifications to index a corpus with a term list
-}
{-# LANGUAGE Strict #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE Strict #-}
{-# LANGUAGE TypeApplications #-}
module Main where
import Prelude
import CLI.FilterTermsAndCooc
import CLI.ObfuscateDB (obfuscateDB, obfuscateDBCmd)
import CLI.Types
import Options.Applicative
import CLI.Admin (adminCLI, adminCmd)
import CLI.FileDiff (fileDiffCLI, fileDiffCmd)
import CLI.FilterTermsAndCooc
import CLI.Import (importCLI, importCmd)
import CLI.Ini (iniCLI, iniCmd)
import CLI.Init (initCLI, initCmd)
import CLI.Invitations (invitationsCLI, invitationsCmd)
import CLI.ObfuscateDB (obfuscateDB, obfuscateDBCmd)
import CLI.Phylo (phyloCLI, phyloCmd)
import CLI.Phylo.Profile (phyloProfileCLI, phyloProfileCmd)
import CLI.Server (serverCLI, serverCmd)
import CLI.Server.Routes (routesCLI, routesCmd)
import CLI.Types
import CLI.Upgrade (upgradeCLI, upgradeCmd)
import CLI.Worker (workerCLI, workerCmd)
import Options.Applicative
import Prelude
runCLI :: CLI -> IO ()
runCLI = \case
......@@ -63,6 +65,8 @@ runCLI = \case
-> fileDiffCLI args
CLISub (CCMD_routes args)
-> routesCLI args
CLISub (CCMD_server args)
-> serverCLI args
CLISub (CCMD_worker args)
-> workerCLI args
......@@ -89,5 +93,6 @@ allOptions = subparser (
upgradeCmd <>
fileDiffCmd <>
routesCmd <>
serverCmd <>
workerCmd
)
{-|
Module : Main.hs
Description : Gargantext starter
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
Script to start gargantext with different modes (Dev, Prod, Mock).
-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE Strict #-}
{-# LANGUAGE TypeOperators #-}
-- {-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE TypeFamilies #-}
module Main where
import Data.Text (unpack)
import Data.Version (showVersion)
import GHC.IO.Encoding
import Gargantext.API (startGargantext) -- , startGargantextMock)
import Gargantext.API.Admin.EnvTypes
import Gargantext.API.Admin.Settings
import Gargantext.Core.Config.Types (SettingsFile(..))
import Gargantext.Prelude
import Gargantext.System.Logging
import Options.Generic
import System.Exit (exitSuccess)
import qualified Paths_gargantext as PG -- cabal magic build module
instance ParseRecord Mode
instance ParseField Mode
instance ParseFields Mode
data MyOptions w =
MyOptions { run :: w ::: Mode
<?> "Possible modes: Dev | Mock | Prod"
, port :: w ::: Maybe Int
<?> "By default: 8008"
, toml :: w ::: Maybe FilePath
<?> "By default: gargantext-settings.toml"
, version :: w ::: Bool
<?> "Show version number and exit"
}
deriving (Generic)
instance ParseRecord (MyOptions Wrapped)
deriving instance Show (MyOptions Unwrapped)
main :: IO ()
main = withLogger () $ \ioLogger -> do
-- Sets the locale to avoid encoding issues like in #284.
setLocaleEncoding utf8
currentLocale <- getLocaleEncoding
MyOptions myMode myPort mb_tomlFile myVersion <- unwrapRecord
"Gargantext server"
---------------------------------------------------------------
if myVersion then do
logMsg ioLogger INFO $ "Version: " <> showVersion PG.version
System.Exit.exitSuccess
else
return ()
---------------------------------------------------------------
let myPort' = case myPort of
Just p -> p
Nothing -> 8008
tomlFile = SettingsFile $ case mb_tomlFile of
Nothing -> "gargantext-settings.toml"
Just i -> i
---------------------------------------------------------------
let start = case myMode of
Mock -> panicTrace "[ERROR] Mock mode unsupported"
_ -> startGargantext myMode myPort' tomlFile
logMsg ioLogger INFO $ "Starting with " <> show myMode <> " mode."
logMsg ioLogger INFO $ "Machine locale: " <> show currentLocale
start
---------------------------------------------------------------
......@@ -651,6 +651,7 @@ executable gargantext-cli
CLI.Phylo
CLI.Phylo.Common
CLI.Phylo.Profile
CLI.Server
CLI.Server.Routes
CLI.Types
CLI.Upgrade
......@@ -694,28 +695,6 @@ executable gargantext-cli
, vector ^>= 0.12.3.0
ghc-options: -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Wmissing-signatures -Wunused-binds -Wunused-imports -Werror -freduction-depth=300 -fprint-potential-instances
executable gargantext-server
import:
defaults
, optimized
main-is: Main.hs
other-modules:
Paths_gargantext
hs-source-dirs:
bin/gargantext-server
build-depends:
cassava ^>= 0.5.2.0
, containers ^>= 0.6.7
, extra ^>= 1.7.9
, gargantext
, gargantext-prelude
, ini ^>= 0.4.1
, optparse-generic ^>= 1.4.7
, postgresql-simple ^>= 0.6.4
, text ^>= 2.0.2
, unordered-containers ^>= 0.2.16.0
, vector ^>= 0.12.3.0
common testDependencies
build-depends:
base >=4.7 && <5
......
......@@ -61,7 +61,7 @@ import System.Log.FastLogger qualified as FL
data Mode = Dev | Mock | Prod
deriving (Show, Read, Generic)
deriving (Show, Read, Generic, Eq)
-- | Given the 'Mode' the server is running in, it returns the list of
-- allowed levels. For example for production we ignore everything which
......
......@@ -63,7 +63,7 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
_ <- sendJobWithCfg cfg Ping
mTimeout <- Timeout.timeout (5 * 1000000) $ do
mTimeout <- Timeout.timeout (5 * 1_000_000) $ do
md <- atomically $ readTChan tchan
md `shouldBe` Just DT.NPing
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment