Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
Odevzdávací Systém MO
Commits
e913aeae
Commit
e913aeae
authored
4 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Spouštění jobů pomocí uwsgi mules
parent
d33c3c91
No related branches found
No related tags found
2 merge requests
!14
Asynchronní joby
,
!9
WIP: Zárodek uživatelské části webu a submitování
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
TODO
+3
-2
3 additions, 2 deletions
TODO
etc/uwsgi.ini.example
+1
-0
1 addition, 0 deletions
etc/uwsgi.ini.example
mo/web/__init__.py
+34
-0
34 additions, 0 deletions
mo/web/__init__.py
setup.py
+1
-0
1 addition, 0 deletions
setup.py
with
39 additions
and
2 deletions
TODO
+
3
−
2
View file @
e913aeae
- select for update
Nasazení:
Nasazení:
- zkontrolovat rotování logů (i u /akce/mathletics/ a jiných instancí uwsgi)
- zkontrolovat rotování logů (i u /akce/mathletics/ a jiných instancí uwsgi)
- zapnout mule v uwsgi.ini
- upgradovat strukturu DB
- doplnit config.py
This diff is collapsed.
Click to expand it.
etc/uwsgi.ini.example
+
1
−
0
View file @
e913aeae
...
@@ -18,5 +18,6 @@ mount = /osmo-test=mo.web:app
...
@@ -18,5 +18,6 @@ mount = /osmo-test=mo.web:app
plugin = python3
plugin = python3
virtualenv = venv
virtualenv = venv
manage-script-name = true
manage-script-name = true
mule
static-map = /static=static
static-map = /static=static
This diff is collapsed.
Click to expand it.
mo/web/__init__.py
+
34
−
0
View file @
e913aeae
...
@@ -13,6 +13,7 @@ import werkzeug.exceptions
...
@@ -13,6 +13,7 @@ import werkzeug.exceptions
import
mo
import
mo
import
mo.config
as
config
import
mo.config
as
config
import
mo.db
as
db
import
mo.db
as
db
import
mo.jobs
import
mo.users
import
mo.users
import
mo.util
import
mo.util
from
mo.util
import
logger
from
mo.util
import
logger
...
@@ -83,6 +84,39 @@ def init_request():
...
@@ -83,6 +84,39 @@ def init_request():
app
.
before_request
(
init_request
)
app
.
before_request
(
init_request
)
### UWSGI glue ###
try
:
import
uwsgi
from
uwsgidecorators
import
timer
,
signal
# Čas od času se probudíme a projdeme joby pro případ, že by se ztratil signál.
# Také při tom expirujeme zastaralé joby.
@timer
(
120
,
target
=
'
mule
'
)
def
mule_timer
(
signum
):
app
.
logger
.
debug
(
'
Mule: Timer tick
'
)
with
app
.
app_context
():
mo
.
now
=
mo
.
util
.
get_now
()
mo
.
jobs
.
process_jobs
()
# Obykle při vložení jobu dostaneme signál.
@signal
(
42
,
target
=
'
mule
'
)
def
mule_signal
(
signum
):
app
.
logger
.
debug
(
'
Mule: Přijat signál
'
)
with
app
.
app_context
():
mo
.
now
=
mo
.
util
.
get_now
()
mo
.
jobs
.
process_jobs
()
def
wake_up_mule
():
app
.
logger
.
debug
(
'
Mule: Posíláme signál
'
)
uwsgi
.
signal
(
42
)
mo
.
jobs
.
send_notify
=
wake_up_mule
except
ImportError
:
app
.
logger
.
warn
(
'
Nenalezeno UWSGI, takže automatické notifikace nepoběží.
'
)
# Většina webu je v samostatných modulech
# Většina webu je v samostatných modulech
import
mo.web.auth
import
mo.web.auth
import
mo.web.menu
import
mo.web.menu
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
0
View file @
e913aeae
...
@@ -30,5 +30,6 @@ setuptools.setup(
...
@@ -30,5 +30,6 @@ setuptools.setup(
'
pikepdf
'
,
'
pikepdf
'
,
'
psycopg2
'
,
'
psycopg2
'
,
'
sqlalchemy
'
,
'
sqlalchemy
'
,
'
uwsgidecorators
'
,
],
],
)
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment