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 OverloadedStrings #-}
18 {-# LANGUAGE StandaloneDeriving #-}
19 {-# LANGUAGE TypeOperators #-}
23 import Prelude (putStrLn)
25 import Options.Generic
26 import Data.Text (unpack)
28 import Gargantext.Prelude
29 import Gargantext.API (startGargantext, startGargantextMock)
30 --------------------------------------------------------
32 data Mode = Dev | Mock | Prod
33 deriving (Show, Read, Generic)
34 instance ParseRecord Mode
35 instance ParseField Mode
36 instance ParseFields Mode
39 data MyOptions w = MyOptions { run :: w ::: Mode <?> "Possible modes: Dev | Mock | Prod"
40 , port :: w ::: Maybe Int <?> "By default: 8008"
41 , ini :: w ::: Maybe Text <?> "Ini-file path of gargantext.ini"
45 instance ParseRecord (MyOptions Wrapped)
46 deriving instance Show (MyOptions Unwrapped)
50 MyOptions myMode myPort myIniFile <- unwrapRecord
51 "Gargantext: collaborative platform for text-mining"
53 let myPort' = case myPort of
57 let start = case myMode of
58 --Nothing -> startGargantext myPort' (unpack myIniFile')
59 Prod -> startGargantext myPort' (unpack myIniFile')
61 myIniFile' = case myIniFile of
62 Nothing -> panic "For Prod mode, you need to fill a gargantext.ini file"
64 Mock -> startGargantextMock myPort'
65 _ -> startGargantextMock myPort'
67 putStrLn $ "Starting Gargantext with mode: " <> show myMode