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
0dfc57df
Commit
0dfc57df
authored
Dec 06, 2017
by
sim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Startup scripts for production servers
parent
9e532889
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
145 additions
and
1 deletion
+145
-1
Makefile
Makefile
+2
-1
gargantext-uwsgi
tools/init.d/gargantext-uwsgi
+140
-0
mkenvs.sh
tools/mkenvs.sh
+3
-0
No files found.
Makefile
View file @
0dfc57df
POSTGREST_INIT
=
./tools/init.d/gargantext-postgrest
BACKEND_INIT
=
./tools/init.d/gargantext-testserver
ifeq
(
"$(ENVIR)"
,
"prod"
)
PIPENV_ARGS
=
BACKEND_INIT
=
./tools/init.d/gargantext-uwsgi
else
ENVIR
=
dev
PIPENV_ARGS
=
--dev
BACKEND_INIT
=
./tools/init.d/gargantext-testserver
endif
PY_VERSION
=
'import sys; v=sys.version_info; print("{0}.{1}".format(*v))'
...
...
tools/init.d/gargantext-uwsgi
0 → 100755
View file @
0dfc57df
#!/bin/sh
### BEGIN INIT INFO
# Provides: gargantext-uwsgi
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts gargantext web server
# Description: starts gargantext production web server using uwsgi
### END INIT INFO
PATH
=
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON
=
$(
which uwsgi
)
NAME
=
gargantext-uwsgi
DESC
=
gargantext-uwsgi
STOP_SCHEDULE
=
"
${
STOP_SCHEDULE
:-
QUIT
/5/TERM/5/KILL/5
}
"
GARGANTEXT_CONF
=
$(
realpath
${
GARGANTEXT_CONF
:-
gargantext
.ini
})
DAEMON_OPTS
=
$GARGANTEXT_CONF
test
-x
"
$DAEMON
"
||
exit
0
.
/lib/init/vars.sh
.
/lib/lsb/init-functions
# Try to extract uwsgi pidfile
PID
=
$(
grep
-oP
'^\s*pidfile\s*=\s*\K.+'
$GARGANTEXT_CONF
|
tail
-1
)
PID
=
${
PID
:-
/tmp/gargantext.pid
}
start
()
{
# Start the daemon/service
#
# Returns:
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
[
-f
"
$PID
"
]
&&
kill
-0
$(
cat
$PID
)
>
/dev/null 2>&1
&&
return
1
$DAEMON
$GARGANTEXT_CONF
>
/dev/null 2>&1
||
return
2
}
test_config
()
{
# Test the gargantext configuration
[
-f
"
$GARGANTEXT_CONF
"
]
}
stop
()
{
# Stops the daemon/service
#
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
[
-f
"
$PID
"
]
||
return
1
kill
-0
$(
cat
$PID
)
>
/dev/null 2>&1
||
return
1
$DAEMON
--stop
$PID
>
/dev/null 2>&1
||
return
2
# uWSGI takes a little time to remove pidfile
sleep
2
}
reload
()
{
# Function that sends a SIGHUP to the daemon/service
[
-f
"
$PID
"
]
||
return
1
$DAEMON
--reload
$PID
>
/dev/null 2>&1
}
case
"
$1
"
in
start
)
log_daemon_msg
"Starting
$DESC
"
"
$NAME
"
start
case
"
$?
"
in
0|1
)
log_end_msg 0
;;
2
)
log_end_msg 1
;;
esac
;;
stop
)
log_daemon_msg
"Stopping
$DESC
"
"
$NAME
"
stop
case
"
$?
"
in
0|1
)
log_end_msg 0
;;
2
)
log_end_msg 1
;;
esac
;;
restart
)
log_daemon_msg
"Restarting
$DESC
"
"
$NAME
"
# Check configuration before stopping nginx
if
!
test_config
;
then
log_end_msg 1
# Configuration error
exit
$?
fi
stop
case
"
$?
"
in
0|1
)
start
case
"
$?
"
in
0
)
log_end_msg 0
;;
1
)
log_end_msg 1
;;
# Old process is still running
*
)
log_end_msg 1
;;
# Failed to start
esac
;;
*
)
# Failed to stop
log_end_msg 1
;;
esac
;;
reload|force-reload
)
log_daemon_msg
"Reloading
$DESC
configuration"
"
$NAME
"
# Check configuration before stopping nginx
#
# This is not entirely correct since the on-disk nginx binary
# may differ from the in-memory one, but that's not common.
# We prefer to check the configuration and return an error
# to the administrator.
if
!
test_config
;
then
log_end_msg 1
# Configuration error
exit
$?
fi
reload
log_end_msg
$?
;;
configtest|testconfig
)
log_daemon_msg
"Testing
$DESC
configuration"
test_config
log_end_msg
$?
;;
status
)
status_of_proc
-p
$PID
"
$DAEMON
"
"
$NAME
"
&&
exit
0
||
exit
$?
;;
*
)
echo
"Usage:
$NAME
{start|stop|restart|reload|force-reload|status|configtest}"
>
&2
exit
3
;;
esac
tools/mkenvs.sh
View file @
0dfc57df
#!/usr/bin/env bash
ENV_FILE
=
.env
ENVIR
=
${
ENVIR
:-
dev
}
DSM
=
gargantext.backend.settings
GARGANTEXT_CONF
=
${
GARGANTEXT_CONF
:-
gargantext
.ini
}
POSTGREST_CONF
=
${
POSTGREST_CONF
:-
postgrest
.conf
}
...
...
@@ -13,6 +14,8 @@ EOF
build_env
()
{
cat
<<
EOF
>
$ENV_FILE
# ENVIR can be dev or prod
ENVIR=
$ENVIR
$DJANGO_VAR
# Paths of configuration files, you're welcome to change that; when a simple
# filename is given, it'll be searched in current directory.
...
...
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