-
Notifications
You must be signed in to change notification settings - Fork 709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
start/stop/status and daemonization #1598
start/stop/status and daemonization #1598
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1598 +/- ##
===========================================
- Coverage 73.08% 71.66% -1.43%
===========================================
Files 148 149 +1
Lines 4882 5025 +143
Branches 532 552 +20
===========================================
+ Hits 3568 3601 +33
- Misses 1248 1357 +109
- Partials 66 67 +1
Continue to review full report at Codecov.
|
Woot! |
|
||
import django # noqa | ||
from django.core.management import call_command # noqa | ||
from docopt import docopt # noqa | ||
|
||
from . import server # noqa | ||
from .system import become_daemon # noqa |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
if not SKIP_AUTO_DATABASE_MIGRATION: | ||
call_command("migrate", interactive=False) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
setup_logging(debug=debug) | ||
|
||
if not os.path.isfile(VERSION_FILE): | ||
_first_run() | ||
else: | ||
version = open(VERSION_FILE, "r").read() | ||
if kolibri.__version__ != version.strip(): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
# TODO: moved from server.start() but not sure where it should ideally be | ||
# located. Question is if it should be run every time the server is started | ||
# or if it depends on some kind of state change. | ||
from kolibri.content.utils.annotation import update_channel_metadata_cache |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
kolibri/utils/cli.py
Outdated
server.STATUS_SERVER_CONFIGURATION_ERROR: 'KA Lite server configuration error', | ||
server.STATUS_PID_FILE_READ_ERROR: 'Could not read PID file', | ||
server.STATUS_PID_FILE_INVALID: 'Invalid PID file', | ||
server.STATUS_UNKNOW: 'Could not determine status', |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
kolibri/utils/server.py
Outdated
STATUS_SERVER_CONFIGURATION_ERROR = 9 | ||
STATUS_PID_FILE_READ_ERROR = 99 | ||
STATUS_PID_FILE_INVALID = 100 | ||
STATUS_UNKNOW = 101 |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Codecov Report
@@ Coverage Diff @@
## develop #1598 +/- ##
===========================================
+ Coverage 73.35% 73.44% +0.08%
===========================================
Files 148 149 +1
Lines 4935 5170 +235
Branches 545 576 +31
===========================================
+ Hits 3620 3797 +177
- Misses 1247 1277 +30
- Partials 68 96 +28
Continue to review full report at Codecov.
|
Clearly in the absence of tests, this isn't very nice, but I'm trying to at least add coverage metrics on the |
…ature/daemonization [ci skip]
Once merged, will open up issues regarding remaining work, especially:
|
Works, let's merge! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works!
Summary
migrate
andcollectstatic
when a change in the version is detected - this provides significant speedups of normalkolibri start
commandstatus
command is implemented, but not broadly tested and has a McCabe complexity of 16start
deliberately skipsstatus
because of the above. If server is already running, it'll fail because the port is unavailablestop
behaviour is also implemented naively, just kills whatever process is in the PID fileTODO
stop
command--foreground
flagReviewer guidance
Please feel free to review code that's committed, it's intended to be merged and improved in 0.6
The WIP means that additional stuff will be added
Issues addressed
#1548
Documentation
See CLI usage spec