3 Description : Gargantext starter
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
10 Script to start gargantext with different modes (Dev, Prod, Mock).
14 {-# LANGUAGE StandaloneDeriving #-}
15 {-# LANGUAGE TypeOperators #-}
16 {-# LANGUAGE Strict #-}
20 import Data.Version (showVersion)
21 import Data.Text (unpack)
22 import qualified Paths_gargantext as PG -- cabal magic build module
23 import Options.Generic
24 import System.Exit (exitSuccess)
26 import Gargantext.Prelude
27 import Gargantext.API (startGargantext, Mode(..)) -- , startGargantextMock)
29 --------------------------------------------------------
31 --import qualified Gargantext.Graph.Utils as U
32 --import qualified Gargantext.Graph.Distances.Conditional as C
33 --import qualified Gargantext.Graph.Distances.Distributional as D
34 --import qualified Gargantext.Graph.Distances.Matrice as M
35 --------------------------------------------------------
37 instance ParseRecord Mode
38 instance ParseField Mode
39 instance ParseFields Mode
42 MyOptions { run :: w ::: Mode
43 <?> "Possible modes: Dev | Mock | Prod"
44 , port :: w ::: Maybe Int
45 <?> "By default: 8008"
46 , ini :: w ::: Maybe Text
47 <?> "Ini-file path of gargantext.ini"
48 , version :: w ::: Bool
49 <?> "Show version number and exit"
53 instance ParseRecord (MyOptions Wrapped)
54 deriving instance Show (MyOptions Unwrapped)
59 MyOptions myMode myPort myIniFile myVersion <- unwrapRecord
63 putStrLn $ "Version: " <> showVersion PG.version
64 System.Exit.exitSuccess
68 let myPort' = case myPort of
72 let start = case myMode of
73 Mock -> panic "[ERROR] Mock mode unsupported"
74 _ -> startGargantext myMode myPort' (unpack myIniFile')
76 myIniFile' = case myIniFile of
77 Nothing -> panic "[ERROR] gargantext.ini needed"
80 putStrLn $ "Starting with " <> show myMode <> " mode."