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
150
Issues
150
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
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
cdef5006
Verified
Commit
cdef5006
authored
Nov 25, 2024
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[worker] cli: run-all subcommand
parent
d78e4177
Pipeline
#7036
canceled with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletion
+36
-1
Types.hs
bin/gargantext-cli/CLI/Types.hs
+18
-0
Worker.hs
bin/gargantext-cli/CLI/Worker.hs
+18
-1
No files found.
bin/gargantext-cli/CLI/Types.hs
View file @
cdef5006
{-|
Module : CLI.Types
Description : CLI types
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE DuplicateRecordFields #-}
module
CLI.Types
where
...
...
@@ -82,6 +95,7 @@ data CLIRoutes
data
CLIWorker
=
CLIW_run
WorkerArgs
|
CLIW_runAll
WorkerAllArgs
|
CLIW_stats
WorkerStatsArgs
deriving
(
Show
,
Eq
)
...
...
@@ -91,6 +105,10 @@ data WorkerArgs = WorkerArgs
,
worker_run_single
::
!
Bool
}
deriving
(
Show
,
Eq
)
data
WorkerAllArgs
=
WorkerAllArgs
{
worker_toml
::
!
SettingsFile
}
deriving
(
Show
,
Eq
)
data
WorkerStatsArgs
=
WorkerStatsArgs
{
ws_toml
::
!
SettingsFile
}
deriving
(
Show
,
Eq
)
...
...
bin/gargantext-cli/CLI/Worker.hs
View file @
cdef5006
{-|
Module :
Worker.hs
Module :
CLI.Worker
Description : Gargantext Job Worker
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
...
...
@@ -16,10 +16,12 @@ import Async.Worker.Broker.Types qualified as BT
import
Async.Worker.Types
qualified
as
W
import
CLI.Types
import
CLI.Parsers
import
Control.Concurrent.Async
(
forConcurrently_
)
import
Data.List
qualified
as
List
(
cycle
,
concat
,
take
)
import
Data.Text
qualified
as
T
import
Gargantext.Core.Config
(
hasConfig
,
gc_worker
)
import
Gargantext.Core.Config.Types
(
SettingsFile
(
..
))
import
Gargantext.Core.Config.Utils
(
readConfig
)
import
Gargantext.Core.Config.Worker
(
WorkerDefinition
(
..
),
WorkerSettings
(
..
),
findDefinitionByName
)
import
Gargantext.Core.Worker
(
withPGMQWorkerCtrlC
,
withPGMQWorkerSingleCtrlC
,
initWorkerState
)
import
Gargantext.Core.Worker.Env
(
withWorkerEnv
)
...
...
@@ -65,6 +67,14 @@ workerCLI (CLIW_run (WorkerArgs { .. })) = do
withPGMQWorkerCtrlC
env
wd
$
\
a
_state
->
do
-- _ <- runReaderT (sendJob Ping) env
wait
a
workerCLI
(
CLIW_runAll
(
WorkerAllArgs
{
..
}))
=
do
cfg
<-
readConfig
worker_toml
let
ws
=
cfg
^.
gc_worker
forConcurrently_
(
_wsDefinitions
ws
)
$
\
wd
->
do
withWorkerEnv
worker_toml
$
\
env
->
do
putStrLn
$
"Starting worker '"
<>
_wdName
wd
<>
"' (queue "
<>
show
(
_wdQueue
wd
)
<>
")"
withPGMQWorkerCtrlC
env
wd
$
\
a
_state
->
do
wait
a
workerCLI
(
CLIW_stats
(
WorkerStatsArgs
{
..
}))
=
do
putStrLn
(
"worker toml: "
<>
_SettingsFile
ws_toml
)
...
...
@@ -95,6 +105,8 @@ workerParser :: Parser CLIWorker
workerParser
=
hsubparser
(
command
"run"
(
info
(
helper
<*>
worker_p
)
(
progDesc
"Run a single worker"
))
<>
command
"run-all"
(
info
(
helper
<*>
worker_all_p
)
(
progDesc
"Run all worker definitions"
))
<>
command
"stats"
(
info
(
helper
<*>
stats_p
)
(
progDesc
"Print queue stats"
))
)
...
...
@@ -108,6 +120,11 @@ worker_p = fmap CLIW_run $ WorkerArgs
<*>
flag
False
True
(
long
"run-single"
<>
help
"Whether to loop or run a single job from queue"
)
worker_all_p
::
Parser
CLIWorker
worker_all_p
=
fmap
CLIW_runAll
$
WorkerAllArgs
<$>
settings_p
stats_p
::
Parser
CLIWorker
stats_p
=
fmap
CLIW_stats
$
WorkerStatsArgs
<$>
settings_p
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