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) -- , 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 data Mode = Dev | Mock | Prod
43 deriving (Show, Read, Generic)
44 instance ParseRecord Mode
45 instance ParseField Mode
46 instance ParseFields Mode
50 MyOptions { run :: w ::: Mode
51 <?> "Possible modes: Dev | Mock | Prod"
52 , port :: w ::: Maybe Int
53 <?> "By default: 8008"
54 , ini :: w ::: Maybe Text
55 <?> "Ini-file path of gargantext.ini"
56 , version :: w ::: Bool
57 <?> "Show version number and exit"
61 instance ParseRecord (MyOptions Wrapped)
62 deriving instance Show (MyOptions Unwrapped)
67 MyOptions myMode myPort myIniFile myVersion <- unwrapRecord
71 putStrLn $ "Version: " <> showVersion PG.version
72 System.Exit.exitSuccess
76 let myPort' = case myPort of
80 let start = case myMode of
81 Prod -> startGargantext myPort' (unpack myIniFile')
83 myIniFile' = case myIniFile of
84 Nothing -> panic "[ERROR] gargantext.ini needed"
86 Dev -> panic "[ERROR] Dev mode unsupported"
87 Mock -> panic "[ERROR] Mock mode unsupported"
88 -- _ -> startGargantextMock myPort'
90 putStrLn $ "Starting with " <> show myMode <> " mode."