]> Git — Sourcephile - gargantext.git/blob - bin/gargantext-server/Main.hs
[Notes MEETING] Phylomemy work with Quentin and David.
[gargantext.git] / bin / gargantext-server / Main.hs
1 {-|
2 Module : Main.hs
3 Description : Gargantext starter
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 Script to start gargantext with different modes (Dev, Prod, Mock).
11
12 -}
13
14 {-# LANGUAGE DataKinds #-}
15 {-# LANGUAGE DeriveGeneric #-}
16 {-# LANGUAGE FlexibleInstances #-}
17 {-# LANGUAGE NoImplicitPrelude #-}
18 {-# LANGUAGE OverloadedStrings #-}
19 {-# LANGUAGE StandaloneDeriving #-}
20 {-# LANGUAGE TypeOperators #-}
21 {-# LANGUAGE Strict #-}
22
23 module Main where
24
25
26 import Options.Generic
27 import Data.Text (unpack)
28
29 import Gargantext.Prelude
30 import Gargantext.API (startGargantext, startGargantextMock)
31
32 --------------------------------------------------------
33 -- Graph Tests
34 --import qualified Gargantext.Graph.Utils as U
35 --import qualified Gargantext.Graph.Distances.Conditional as C
36 --import qualified Gargantext.Graph.Distances.Distributional as D
37 --import qualified Gargantext.Graph.Distances.Matrice as M
38 --------------------------------------------------------
39
40 data Mode = Dev | Mock | Prod
41 deriving (Show, Read, Generic)
42 instance ParseRecord Mode
43 instance ParseField Mode
44 instance ParseFields Mode
45
46
47 data MyOptions w =
48 MyOptions { run :: w ::: Mode
49 <?> "Possible modes: Dev | Mock | Prod"
50 , port :: w ::: Maybe Int
51 <?> "By default: 8008"
52 , ini :: w ::: Maybe Text
53 <?> "Ini-file path of gargantext.ini"
54 }
55 deriving (Generic)
56
57 instance ParseRecord (MyOptions Wrapped)
58 deriving instance Show (MyOptions Unwrapped)
59
60
61 main :: IO ()
62 main = do
63 MyOptions myMode myPort myIniFile <- unwrapRecord
64 "Gargantext server"
65
66 let myPort' = case myPort of
67 Just p -> p
68 Nothing -> 8008
69
70 let start = case myMode of
71 Prod -> startGargantext myPort' (unpack myIniFile')
72 where
73 myIniFile' = case myIniFile of
74 Nothing -> panic "[ERROR] gargantext.ini needed"
75 Just i -> i
76 _ -> startGargantextMock myPort'
77
78 putStrLn $ "Starting with " <> show myMode <> " mode."
79 start
80