Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
195
Issues
195
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
2fdd28e1
Commit
2fdd28e1
authored
Sep 05, 2022
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/garg-init-errror-msg' into dev-merge
parents
5c804582
cc5cef13
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
API.hs
src/Gargantext/API.hs
+15
-1
Prelude.hs
src/Gargantext/Database/Prelude.hs
+9
-3
No files found.
src/Gargantext/API.hs
View file @
2fdd28e1
...
@@ -31,10 +31,13 @@ Pouillard (who mainly made it).
...
@@ -31,10 +31,13 @@ Pouillard (who mainly made it).
module
Gargantext.API
module
Gargantext.API
where
where
import
Control.Exception
(
finally
)
import
Control.Exception
(
catch
,
finally
,
SomeException
)
import
Control.Lens
import
Control.Lens
import
Control.Monad.Except
import
Control.Monad.Reader
(
runReaderT
)
import
Control.Monad.Reader
(
runReaderT
)
import
Data.Either
import
Data.List
(
lookup
)
import
Data.List
(
lookup
)
import
Data.Text
(
pack
)
import
Data.Text.Encoding
(
encodeUtf8
)
import
Data.Text.Encoding
(
encodeUtf8
)
import
Data.Text.IO
(
putStrLn
)
import
Data.Text.IO
(
putStrLn
)
import
Data.Validity
import
Data.Validity
...
@@ -49,6 +52,7 @@ import Gargantext.API.Prelude
...
@@ -49,6 +52,7 @@ import Gargantext.API.Prelude
import
Gargantext.API.Routes
import
Gargantext.API.Routes
import
Gargantext.API.Server
(
server
)
import
Gargantext.API.Server
(
server
)
import
Gargantext.Core.NodeStory
import
Gargantext.Core.NodeStory
import
qualified
Gargantext.Database.Prelude
as
DB
import
Gargantext.Prelude
hiding
(
putStrLn
)
import
Gargantext.Prelude
hiding
(
putStrLn
)
import
Network.HTTP.Types
hiding
(
Query
)
import
Network.HTTP.Types
hiding
(
Query
)
import
Network.Wai
import
Network.Wai
...
@@ -66,11 +70,21 @@ data Mode = Dev | Mock | Prod
...
@@ -66,11 +70,21 @@ data Mode = Dev | Mock | Prod
startGargantext
::
Mode
->
PortNumber
->
FilePath
->
IO
()
startGargantext
::
Mode
->
PortNumber
->
FilePath
->
IO
()
startGargantext
mode
port
file
=
do
startGargantext
mode
port
file
=
do
env
<-
newEnv
port
file
env
<-
newEnv
port
file
runDbCheck
env
portRouteInfo
port
portRouteInfo
port
app
<-
makeApp
env
app
<-
makeApp
env
mid
<-
makeDevMiddleware
mode
mid
<-
makeDevMiddleware
mode
run
port
(
mid
app
)
`
finally
`
stopGargantext
env
run
port
(
mid
app
)
`
finally
`
stopGargantext
env
where
runDbCheck
env
=
do
r
<-
runExceptT
(
runReaderT
DB
.
dbCheck
env
)
`
catch
`
(
\
(
_
::
SomeException
)
->
return
$
Right
False
)
case
r
of
Right
True
->
return
()
_
->
panic
$
"You must run 'gargantext-init "
<>
pack
file
<>
"' before running gargantext-server (only the first time)."
portRouteInfo
::
PortNumber
->
IO
()
portRouteInfo
::
PortNumber
->
IO
()
portRouteInfo
port
=
do
portRouteInfo
port
=
do
putStrLn
" ----Main Routes----- "
putStrLn
" ----Main Routes----- "
...
...
src/Gargantext/Database/Prelude.hs
View file @
2fdd28e1
...
@@ -9,7 +9,7 @@ Portability : POSIX
...
@@ -9,7 +9,7 @@ Portability : POSIX
-}
-}
{-# LANGUAGE ConstraintKinds
#-}
{-# LANGUAGE ConstraintKinds
, ScopedTypeVariables
#-}
module
Gargantext.Database.Prelude
where
module
Gargantext.Database.Prelude
where
...
@@ -30,6 +30,7 @@ import Data.Word (Word16)
...
@@ -30,6 +30,7 @@ import Data.Word (Word16)
import
Database.PostgreSQL.Simple
(
Connection
,
connect
)
import
Database.PostgreSQL.Simple
(
Connection
,
connect
)
import
Database.PostgreSQL.Simple.FromField
(
Conversion
,
ResultError
(
ConversionFailed
),
fromField
,
returnError
)
import
Database.PostgreSQL.Simple.FromField
(
Conversion
,
ResultError
(
ConversionFailed
),
fromField
,
returnError
)
import
Database.PostgreSQL.Simple.Internal
(
Field
)
import
Database.PostgreSQL.Simple.Internal
(
Field
)
import
Database.PostgreSQL.Simple.Types
(
Query
(
..
))
import
Gargantext.Core.Mail.Types
(
HasMail
)
import
Gargantext.Core.Mail.Types
(
HasMail
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Prelude.Config
(
readIniFile'
,
val
)
import
Gargantext.Prelude.Config
(
readIniFile'
,
val
)
...
@@ -167,10 +168,9 @@ runPGSQuery_ :: ( CmdM env err m
...
@@ -167,10 +168,9 @@ runPGSQuery_ :: ( CmdM env err m
runPGSQuery_
q
=
mkCmd
$
\
conn
->
catch
(
PGS
.
query_
conn
q
)
printError
runPGSQuery_
q
=
mkCmd
$
\
conn
->
catch
(
PGS
.
query_
conn
q
)
printError
where
where
printError
(
SomeException
e
)
=
do
printError
(
SomeException
e
)
=
do
printDebug
"[G.D.P.runPGSQuery_]"
(
"TODO: format query error"
::
Text
)
hPutStrLn
stderr
(
fromQuery
q
)
throw
(
SomeException
e
)
throw
(
SomeException
e
)
execPGSQuery
::
PGS
.
ToRow
a
=>
PGS
.
Query
->
a
->
Cmd
err
Int64
execPGSQuery
::
PGS
.
ToRow
a
=>
PGS
.
Query
->
a
->
Cmd
err
Int64
execPGSQuery
q
a
=
mkCmd
$
\
conn
->
PGS
.
execute
conn
q
a
execPGSQuery
q
a
=
mkCmd
$
\
conn
->
PGS
.
execute
conn
q
a
...
@@ -209,3 +209,9 @@ fromField' field mb = do
...
@@ -209,3 +209,9 @@ fromField' field mb = do
printSqlOpa
::
Default
Unpackspec
a
a
=>
Select
a
->
IO
()
printSqlOpa
::
Default
Unpackspec
a
a
=>
Select
a
->
IO
()
printSqlOpa
=
putStrLn
.
maybe
"Empty query"
identity
.
showSql
printSqlOpa
=
putStrLn
.
maybe
"Empty query"
identity
.
showSql
dbCheck
::
CmdM
env
err
m
=>
m
Bool
dbCheck
=
do
r
::
[
PGS
.
Only
Text
]
<-
runPGSQuery_
"select username from public.auth_user"
case
r
of
[]
->
return
False
_
->
return
True
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment