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 DataKinds #-}
15 {-# LANGUAGE DeriveGeneric #-}
16 {-# LANGUAGE FlexibleInstances #-}
17 {-# LANGUAGE NoImplicitPrelude #-}
18 {-# LANGUAGE OverloadedStrings #-}
19 {-# LANGUAGE StandaloneDeriving #-}
20 {-# LANGUAGE TypeOperators #-}
21 {-# LANGUAGE Strict #-}
25 import Data.Version (showVersion)
26 import Data.Text (unpack)
27 import qualified Paths_gargantext as PG -- cabal magic build module
28 import Options.Generic
29 import System.Exit (exitSuccess)
31 import Gargantext.Prelude
32 import Gargantext.API (startGargantext, Mode(..)) -- , startGargantextMock)
34 --------------------------------------------------------
36 --import qualified Gargantext.Graph.Utils as U
37 --import qualified Gargantext.Graph.Distances.Conditional as C
38 --import qualified Gargantext.Graph.Distances.Distributional as D
39 --import qualified Gargantext.Graph.Distances.Matrice as M
40 --------------------------------------------------------
42 instance ParseRecord Mode
43 instance ParseField Mode
44 instance ParseFields Mode
47 MyOptions { run :: w ::: Mode
48 <?> "Possible modes: Dev | Mock | Prod"
49 , port :: w ::: Maybe Int
50 <?> "By default: 8008"
51 , ini :: w ::: Maybe Text
52 <?> "Ini-file path of gargantext.ini"
53 , version :: w ::: Bool
54 <?> "Show version number and exit"
58 instance ParseRecord (MyOptions Wrapped)
59 deriving instance Show (MyOptions Unwrapped)
64 MyOptions myMode myPort myIniFile myVersion <- unwrapRecord
68 putStrLn $ "Version: " <> showVersion PG.version
69 System.Exit.exitSuccess
73 let myPort' = case myPort of
77 let start = case myMode of
78 Mock -> panic "[ERROR] Mock mode unsupported"
79 _ -> startGargantext myMode myPort' (unpack myIniFile')
81 myIniFile' = case myIniFile of
82 Nothing -> panic "[ERROR] gargantext.ini needed"
85 putStrLn $ "Starting with " <> show myMode <> " mode."