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
147
Issues
147
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
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
ca5569fb
Commit
ca5569fb
authored
Feb 07, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CONFIG] Start server and DB connexion with Ini file (added to the repo for tests).
parent
6fc8d8e9
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
173 additions
and
62 deletions
+173
-62
Main.hs
app/Main.hs
+9
-4
gargantext.cabal
gargantext.cabal
+20
-3
gargantext.ini
gargantext.ini
+65
-0
moduleDesc.model
moduleDesc.model
+3
-3
package.yaml
package.yaml
+14
-2
Ngram.hs
src/Gargantext/Database/Ngram.hs
+2
-6
NodeNgram.hs
src/Gargantext/Database/NodeNgram.hs
+2
-5
NodeNgramNgram.hs
src/Gargantext/Database/NodeNgramNgram.hs
+2
-6
NodeNode.hs
src/Gargantext/Database/NodeNode.hs
+2
-5
NodeNodeNgram.hs
src/Gargantext/Database/NodeNodeNgram.hs
+2
-5
Private.hs
src/Gargantext/Database/Private.hs
+28
-6
User.hs
src/Gargantext/Database/User.hs
+4
-9
Server.hs
src/Gargantext/Server.hs
+20
-8
No files found.
app/Main.hs
View file @
ca5569fb
{-# LANGUAGE NoImplicitPrelude #-}
module
Main
where
--import System.Environment (getArgs)
import
Data.Gargantext.Server
(
startGargantext
)
import
Gargantext.Prelude
import
Gargantext.Server
(
startGargantext
)
import
System.Environment
(
getArgs
)
main
::
IO
()
-- (iniFile:_) <- getArgs
main
=
startGargantext
-- port iniFile
main
=
do
(
iniFile
:
_
)
<-
getArgs
startGargantext
iniFile
gargantext.cabal
View file @
ca5569fb
...
...
@@ -2,7 +2,7 @@
--
-- see: https://github.com/sol/hpack
--
-- hash:
b9bfa189420281ceb8fe8d47b1d7800acdc1f9529c864156abcbfbfea5e06dc
6
-- hash:
1afbb68941e4a0da5a3c812595ca12ed611c36aa9ab55736742c3f093dbf7f0
6
name: gargantext
version: 0.1.0.0
...
...
@@ -11,9 +11,9 @@ description: Please see README.md
homepage: https://gargantext.org
license: BSD3
license-file: LICENSE
author:
Alexandre Delanoë
author:
Gargantext Team
maintainer: team@gargantext.org
copyright: Copyright: (c) 201
6
,
copyright: Copyright: (c) 201
7
,
2018 CNRS Alexandre Delanoë
category: Data
build-type: Simple
...
...
@@ -41,6 +41,7 @@ library
, extra
, filepath
, http-conduit
, ini
, lens
, logging-effect
, opaleye
...
...
@@ -116,6 +117,22 @@ library
default-language: Haskell2010
ghc-options: -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Werror
executable gargantext
main-is: Main.hs
hs-source-dirs:
app
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N -O2
build-depends:
base
, extra
, gargantext
, ini
, text
, unordered-containers
other-modules:
Paths_gargantext
default-language: Haskell2010
test-suite garg-doctest
type: exitcode-stdio-1.0
main-is: Main.hs
...
...
gargantext.ini
0 → 100644
View file @
ca5569fb
[django]
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG
=
True
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY
=
%4{Vs(Pc!GU-]@OaAl0)(*4/yERwU<ct`ncV{1)O%32$6q
# Space-separated list of hosts
ALLOWED_HOSTS
=
localhost
# Time-zone, possible values here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
TIME_ZONE
=
Europe/Paris
# PostgreSQL access
DB_HOST
=
127.0.0.1
DB_PORT
=
5432
DB_NAME
=
gargandb
DB_USER
=
gargantua
DB_PASS
=
C8kdcUrAQy66U
# Logs
LOG_FILE
=
/var/log/gargantext/backend/django.log
LOG_LEVEL
=
DEBUG
LOG_FORMATTER
=
verbose
# Pidfile of django backend test server
TESTSERVER_PIDFILE
=
/tmp/gargantext_testserver.pid
# Celery
CELERYD_PID_FILE
=
/tmp/celery.pid
CELERYD_LOG_FILE
=
/var/log/gargantext/backend/celery.log
CELERYD_LOG_LEVEL
=
DEBUG
[uwsgi]
# See: http://uwsgi-docs.readthedocs.io/en/latest/ThingsToKnow.html
# And: http://uwsgi-docs.readthedocs.io/en/latest/articles/TheArtOfGracefulReloading.html
# Tip from: https://serverfault.com/questions/411361/uwsgi-ini-configuration-for-python-apps
if-env
=
VIRTUAL_ENV
print
=
[uWSGI] launched from virtualenv %(_)
virtualenv
=
%(_)
endif
=
# needed to run uwsgi when it was not installed with pipenv
plugins
=
python35
# needed to run uwsgi outside of pipenv shell, because of this virtualenv bug:
# https://github.com/kennethreitz/pipenv/issues/829
home
=
/home/alexandre/.local/share/virtualenvs/gargantext-ykNZD4Cw
# unix socket is better than TCP one, there is less overhead
socket
=
/tmp/gargantext.sock
chmod-socket
=
664
# user running uwsgi MUST be a member of www-data group
chown-socket
=
%U:www-data
# wsgi django module
module
=
gargantext.backend.wsgi:application
# about master: http://uwsgi-docs.readthedocs.io/en/latest/Management.html?highlight=master#reloading-the-server
master
=
True
# can do: uwsgi --stop /tmp/gargantext.pid
pidfile
=
/tmp/gargantext.pid
# clear environment on exit
vacuum
=
True
max-requests
=
5000
# background the process & log
daemonize
=
/var/log/gargantext/uwsgi/@(exec://date +%%Y-%%m-%%d).log
logfile-chmod
=
644
# one log file per day
log-reopen
=
true
# touch /tmp/gargantext.reload to reload configuration (after git pull for instance)
touch-reload
=
/tmp/gargantext.reload
moduleDesc.model
View file @
ca5569fb
{-|
Module :
Data.Gargantext..
.
Description :
Short description
Copyright : (c) CNRS, 2017
Module :
Gargantext
.
Description :
Copyright : (c) CNRS, 2017
-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
...
...
package.yaml
View file @
ca5569fb
...
...
@@ -3,10 +3,10 @@ version: '0.1.0.0'
synopsis
:
Deep (Collaborative) Text mining project
description
:
Please see README.md
category
:
Data
author
:
Alexandre Delanoë
author
:
Gargantext Team
maintainer
:
team@gargantext.org
copyright
:
-
!
'
Copyright:
(c)
201
6
'
-
!
'
Copyright:
(c)
201
7
'
-
2018 CNRS Alexandre Delanoë
license
:
BSD3
homepage
:
https://gargantext.org
...
...
@@ -73,6 +73,7 @@ library:
-
duckling
-
filepath
-
http-conduit
-
ini
-
lens
-
logging-effect
-
opaleye
...
...
@@ -108,6 +109,17 @@ library:
-
zlib
-
zip
-
path-io
executable
:
main
:
Main.hs
source-dirs
:
app
ghc-options
:
-threaded -rtsopts -with-rtsopts=-N -O2
dependencies
:
-
gargantext
-
ini
-
base
-
unordered-containers
tests
:
garg-test
:
main
:
Main.hs
...
...
src/Gargantext/Database/Ngram.hs
View file @
ca5569fb
...
...
@@ -15,8 +15,6 @@ import qualified Database.PostgreSQL.Simple as PGS
import
Opaleye
import
Gargantext.Database.Private
(
infoGargandb
)
-- Functions only
import
Data.List
(
find
)
...
...
@@ -66,7 +64,5 @@ findWith f t = find (\x -> f x == t)
--userWithId t xs = userWith userUserId t xs
-- | not optimized (get all ngrams without filters)
ngrams
::
IO
[
Ngram
]
ngrams
=
do
conn
<-
PGS
.
connect
infoGargandb
runQuery
conn
queryNgramTable
ngrams
::
PGS
.
Connection
->
IO
[
Ngram
]
ngrams
conn
=
runQuery
conn
queryNgramTable
src/Gargantext/Database/NodeNgram.hs
View file @
ca5569fb
...
...
@@ -16,7 +16,6 @@ import qualified Database.PostgreSQL.Simple as PGS
import
Opaleye
import
Gargantext.Database.Private
(
infoGargandb
)
data
NodeNgramPoly
id
node_id
ngram_id
weight
=
NodeNgram
{
nodeNgram_NodeNgramId
::
id
...
...
@@ -56,7 +55,5 @@ instance QueryRunnerColumnDefault PGFloat8 (Maybe Double) where
-- | not optimized (get all ngrams without filters)
nodeNgrams
::
IO
[
NodeNgram
]
nodeNgrams
=
do
conn
<-
PGS
.
connect
infoGargandb
runQuery
conn
queryNodeNgramTable
nodeNgrams
::
PGS
.
Connection
->
IO
[
NodeNgram
]
nodeNgrams
conn
=
runQuery
conn
queryNodeNgramTable
src/Gargantext/Database/NodeNgramNgram.hs
View file @
ca5569fb
...
...
@@ -15,8 +15,6 @@ import qualified Database.PostgreSQL.Simple as PGS
import
Opaleye
import
Gargantext.Database.Private
(
infoGargandb
)
data
NodeNgramNgramPoly
node_id
ngram1_id
ngram2_id
weight
=
NodeNgramNgram
{
nodeNgramNgram_NodeNgramNgram_NodeId
::
node_id
,
nodeNgramNgram_NodeNgramNgram_Ngram1Id
::
ngram1_id
...
...
@@ -50,10 +48,8 @@ queryNodeNgramNgramTable = queryTable nodeNgramNgramTable
-- | not optimized (get all ngrams without filters)
nodeNgramNgrams
::
IO
[
NodeNgramNgram
]
nodeNgramNgrams
=
do
conn
<-
PGS
.
connect
infoGargandb
runQuery
conn
queryNodeNgramNgramTable
nodeNgramNgrams
::
PGS
.
Connection
->
IO
[
NodeNgramNgram
]
nodeNgramNgrams
conn
=
runQuery
conn
queryNodeNgramNgramTable
instance
QueryRunnerColumnDefault
PGInt4
(
Maybe
Int
)
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
...
...
src/Gargantext/Database/NodeNode.hs
View file @
ca5569fb
...
...
@@ -15,7 +15,6 @@ import qualified Database.PostgreSQL.Simple as PGS
import
Opaleye
import
Gargantext.Database.Private
(
infoGargandb
)
data
NodeNodePoly
node1_id
node2_id
score
=
NodeNode
{
nodeNode_node1_id
::
node1_id
...
...
@@ -46,10 +45,8 @@ queryNodeNodeTable = queryTable nodeNodeTable
-- | not optimized (get all ngrams without filters)
nodeNodes
::
IO
[
NodeNode
]
nodeNodes
=
do
conn
<-
PGS
.
connect
infoGargandb
runQuery
conn
queryNodeNodeTable
nodeNodes
::
PGS
.
Connection
->
IO
[
NodeNode
]
nodeNodes
conn
=
runQuery
conn
queryNodeNodeTable
instance
QueryRunnerColumnDefault
PGFloat8
(
Maybe
Double
)
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
src/Gargantext/Database/NodeNodeNgram.hs
View file @
ca5569fb
...
...
@@ -16,7 +16,6 @@ import qualified Database.PostgreSQL.Simple as PGS
import
Opaleye
import
Gargantext.Database.Private
(
infoGargandb
)
data
NodeNodeNgramPoly
node1_id
node2_id
ngram_id
score
=
NodeNodeNgram
{
nodeNodeNgram_node1_id
::
node1_id
...
...
@@ -51,10 +50,8 @@ queryNodeNodeNgramTable = queryTable nodeNodeNgramTable
-- | not optimized (get all ngrams without filters)
nodeNodeNgrams
::
IO
[
NodeNodeNgram
]
nodeNodeNgrams
=
do
conn
<-
PGS
.
connect
infoGargandb
runQuery
conn
queryNodeNodeNgramTable
nodeNodeNgrams
::
PGS
.
Connection
->
IO
[
NodeNodeNgram
]
nodeNodeNgrams
conn
=
runQuery
conn
queryNodeNodeNgramTable
instance
QueryRunnerColumnDefault
PGFloat8
(
Maybe
Double
)
where
...
...
src/Gargantext/Database/Private.hs
View file @
ca5569fb
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleContexts #-}
module
Gargantext.Database.Private
where
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
Data.Monoid
((
<>
))
import
Data.Either.Extra
(
Either
(
Left
,
Right
))
import
Gargantext.Prelude
import
Data.Text
(
unpack
,
pack
)
import
Text.Read
(
read
)
import
Data.Ini
(
readIniFile
,
lookupValue
)
import
Data.Word
(
Word16
)
import
System.IO
(
FilePath
)
-- TODO add a reader Monad here
-- read this in the init file
infoGargandb
::
PGS
.
ConnectInfo
infoGargandb
=
PGS
.
ConnectInfo
{
PGS
.
connectHost
=
"127.0.0.1"
,
PGS
.
connectPort
=
5432
,
PGS
.
connectUser
=
"gargantua"
,
PGS
.
connectPassword
=
"C8kdcUrAQy66U"
,
PGS
.
connectDatabase
=
"gargandb"
}
databaseParameters
::
FilePath
->
IO
PGS
.
ConnectInfo
databaseParameters
fp
=
do
ini
<-
readIniFile
fp
let
ini''
=
case
ini
of
Left
e
->
panic
(
pack
$
"No ini file error"
<>
show
e
)
Right
ini'
->
ini'
let
val
x
=
case
(
lookupValue
(
pack
"django"
)
(
pack
x
)
ini''
)
of
Left
_
->
panic
(
pack
$
"no"
<>
x
)
Right
p'
->
unpack
p'
pure
$
PGS
.
ConnectInfo
{
PGS
.
connectHost
=
val
"DB_HOST"
,
PGS
.
connectPort
=
read
(
val
"DB_PORT"
)
::
Word16
,
PGS
.
connectUser
=
val
"DB_USER"
,
PGS
.
connectPassword
=
val
"DB_PASS"
,
PGS
.
connectDatabase
=
val
"DB_NAME"
}
src/Gargantext/Database/User.hs
View file @
ca5569fb
...
...
@@ -22,7 +22,6 @@ import Control.Arrow (returnA)
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
Opaleye
import
Gargantext.Database.Private
(
infoGargandb
)
-- Functions only
import
Data.List
(
find
)
...
...
@@ -114,12 +113,8 @@ instance QueryRunnerColumnDefault PGTimestamptz (Maybe UTCTime) where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
users
::
IO
[
User
]
users
=
do
conn
<-
PGS
.
connect
infoGargandb
runQuery
conn
queryUserTable
users
::
PGS
.
Connection
->
IO
[
User
]
users
conn
=
runQuery
conn
queryUserTable
usersLight
::
IO
[
UserLight
]
usersLight
=
do
conn
<-
PGS
.
connect
infoGargandb
map
toUserLight
<$>
runQuery
conn
queryUserTable
usersLight
::
PGS
.
Connection
->
IO
[
UserLight
]
usersLight
conn
=
map
toUserLight
<$>
runQuery
conn
queryUserTable
src/Gargantext/Server.hs
View file @
ca5569fb
{-|
Module : Gargantext.Server
Description : Server API
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TemplateHaskell #-}
...
...
@@ -18,10 +30,11 @@ import Servant
import
Servant.Multipart
import
Database.PostgreSQL.Simple
(
Connection
,
connect
)
import
Opaleye
import
System.IO
(
FilePath
)
import
Gargantext.Types.Main
(
Node
,
NodeId
)
import
Gargantext.Database.Node
(
getNodesWithParentId
,
getNode
)
import
Gargantext.Database.Private
(
infoGargandb
)
import
Gargantext.Database.Private
(
databaseParameters
)
-- | TODO, use MOCK feature of Servant to generate fake data (for tests)
...
...
@@ -44,13 +57,13 @@ server conn
where
echo
s
=
pure
s
connectGargandb
::
IO
Connection
connectGargandb
=
connect
infoGargandb
startGargantext
::
IO
()
startGargantext
=
do
startGargantext
::
FilePath
->
IO
()
startGargantext
file
=
do
print
(
"Starting server on port "
++
show
port
)
conn
<-
connectGargandb
param
<-
databaseParameters
file
conn
<-
connect
param
run
port
$
app
conn
where
port
=
8008
...
...
@@ -75,7 +88,6 @@ nodeAPI conn id
where
id'
=
pgInt4
id
-- | Upload files
-- TODO Is it possible to adapt the function according to iValue input ?
upload
::
MultipartData
->
Handler
String
...
...
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