Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
0c8d3c22
Commit
0c8d3c22
authored
Jan 15, 2018
by
sim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] Celery auto-reload
parent
ceb2c62b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
8 deletions
+22
-8
gargantext-testserver
tools/init.d/gargantext-testserver
+22
-8
No files found.
tools/init.d/gargantext-testserver
View file @
0c8d3c22
...
@@ -33,14 +33,28 @@ test -x "$DAEMON" || exit 0
...
@@ -33,14 +33,28 @@ test -x "$DAEMON" || exit 0
PID
=
$(
grep
-oP
'^\s*TESTSERVER_PIDFILE\s*=\s*\K.+'
$GARGANTEXT_CONF
|
tail
-1
)
PID
=
$(
grep
-oP
'^\s*TESTSERVER_PIDFILE\s*=\s*\K.+'
$GARGANTEXT_CONF
|
tail
-1
)
PID
=
${
PID
:-
/tmp/gargantext_testserver.pid
}
PID
=
${
PID
:-
/tmp/gargantext_testserver.pid
}
reload_celery_when_needed
()
{
gargantext_reload_celery_when_needed
()
{
[
-s
"
$PID
"
]
&&
PPID
=
$(
cat
$PID
)
&&
CHILD
=
$(
pgrep
-P
$PPID
)
# Can't reference global variables from this function, so get parameters
[
-n
"
$PPID
"
-a
-n
"
$CHILD
"
]
&&
\
# from arguments; PID is the pidfile of django test server
((
while
kill
-0
$CHILD
;
do
sleep
1
;
done
)
&&
\
PID
=
"
$1
"
kill
-0
$PPID
&&
\
CELERY_INIT
=
"
$2
"
# Wait for testserver to start to get the correct pid
sleep
2
# Watch testserver and restart celery when it stops, provided that
# testserver is not totally stopped (to check this we check its parent
# process), and celery is running
[
-s
"
$PID
"
]
&&
PARENT_PID
=
$(
cat
$PID
)
&&
CHILD
=
$(
pgrep
-P
$PARENT_PID
)
[
-s
"
$PID
"
-a
-n
"
$PARENT_PID
"
-a
-n
"
$CHILD
"
]
&&
\
((
while
kill
-0
"
$CHILD
"
;
do
sleep
1
;
done
)
&&
\
kill
-0
"
$PARENT_PID
"
&&
\
$CELERY_INIT
status
&&
\
$CELERY_INIT
status
&&
\
$CELERY_INIT
restart
)
>
/dev/null 2>&1
$CELERY_INIT
restart
)
>
/dev/null 2>&1
kill
-0
$PPID
>
/dev/null 2>&1
&&
reload_celery_when_needed
# Start again...
kill
-0
"
$PARENT_PID
"
>
/dev/null 2>&1
&&
\
gargantext_reload_celery_when_needed
"
$PID
"
"
$CELERY_INIT
"
}
}
start
()
{
start
()
{
...
@@ -83,8 +97,8 @@ start() {
...
@@ -83,8 +97,8 @@ start() {
# Wait for a restart in the background and reload celery if needed. We need
# Wait for a restart in the background and reload celery if needed. We need
# to export function and exec a new bash with nohup, otherwise current
# to export function and exec a new bash with nohup, otherwise current
# process would be attached to current terminal.
# process would be attached to current terminal.
export
-f
reload_celery_when_needed
export
-f
gargantext_
reload_celery_when_needed
nohup
$BASH
-c
reload_celery_when_needed
>
/dev/null 2>&1 &
nohup
$BASH
-c
"gargantext_reload_celery_when_needed '
$PID
' '
$CELERY_INIT
'"
>
/dev/null 2>&1 &
}
}
test_config
()
{
test_config
()
{
...
...
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