Skip to content
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

Merged
merged 12 commits into from
Jun 7, 2017

Conversation

benjaoming
Copy link
Contributor

@benjaoming benjaoming commented Jun 6, 2017

Summary

  • Changes the way that we initialize stuff, only running migrate and collectstatic when a change in the version is detected - this provides significant speedups of normal kolibri start command
  • The status command is implemented, but not broadly tested and has a McCabe complexity of 16
  • Running start deliberately skips status because of the above. If server is already running, it'll fail because the port is unavailable
  • stop behaviour is also implemented naively, just kills whatever process is in the PID file

TODO

  • Daemon logic
  • stop command
  • --foreground flag
  • Have tests been written for the new code?
  • Has documentation been written/updated?
  • New dependencies (if any) added to requirements file
  • Add an entry to CHANGELOG.rst
  • Add yourself it AUTHORS.rst if you don't appear there

Reviewer 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

@benjaoming benjaoming added TODO: needs gherkin update Add to our manual integration tests bug Behavior is wrong or broken TAG: new feature New user-facing feature labels Jun 6, 2017
@benjaoming benjaoming added this to the 0.5.0 milestone Jun 6, 2017
@codecov-io
Copy link

codecov-io commented Jun 6, 2017

Codecov Report

Merging #1598 into develop will decrease coverage by 1.42%.
The diff coverage is 25.9%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ
kolibri/utils/system.py 20.51% <20.51%> (ø)
kolibri/utils/cli.py 30.76% <22.91%> (-6.55%) ⬇️
kolibri/utils/server.py 32.11% <30.37%> (+2.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e5975ab...342961b. Read the comment docs.

@rtibbles
Copy link
Member

rtibbles commented Jun 6, 2017

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.

This comment was marked as spam.

This comment was marked as spam.

if not SKIP_AUTO_DATABASE_MIGRATION:
call_command("migrate", interactive=False)

This comment was marked as spam.

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.

# 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.

This comment was marked as spam.

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.

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.

@codecov-io
Copy link

codecov-io commented Jun 6, 2017

Codecov Report

Merging #1598 into develop will increase coverage by 0.08%.
The diff coverage is 45.17%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ
kolibri/deployment/default/settings/test.py 100% <100%> (ø) ⬆️
kolibri/utils/system.py 32.92% <32.92%> (ø)
kolibri/utils/server.py 42.51% <44.32%> (+12.51%) ⬆️
kolibri/utils/cli.py 60.5% <58.22%> (+23.18%) ⬆️
kolibri/deployment/default/settings/base.py 100% <0%> (+8.33%) ⬆️
kolibri/plugins/base.py 72.22% <0%> (+11.11%) ⬆️
kolibri/content/utils/channels.py 35.59% <0%> (+11.86%) ⬆️
kolibri/utils/conf.py 92% <0%> (+36%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1afa091...34697f6. Read the comment docs.

@benjaoming
Copy link
Contributor Author

Clearly in the absence of tests, this isn't very nice, but I'm trying to at least add coverage metrics on the kolibri commands invoked directly in the tox matrix... seems sort of fair :)

@benjaoming benjaoming changed the title [WIP] start/stop/status and daemonization start/stop/status and daemonization Jun 6, 2017
@benjaoming
Copy link
Contributor Author

Once merged, will open up issues regarding remaining work, especially:

  • Adding real tests (possibly undoing what I added to tox.ini just now)
  • Checking get_status before starting the server

@rtibbles
Copy link
Member

rtibbles commented Jun 7, 2017

Works, let's merge!

Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works!

@rtibbles rtibbles merged commit 11f08ea into learningequality:develop Jun 7, 2017
@benjaoming benjaoming deleted the feature/daemonization branch June 7, 2017 12:38
@radinamatic radinamatic removed the TODO: needs gherkin update Add to our manual integration tests label Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Behavior is wrong or broken TAG: new feature New user-facing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants