forked from openedx/license-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9135dd2
commit d803812
Showing
15 changed files
with
311 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
[main] | ||
host = https://www.transifex.com | ||
|
||
[edx-platform.license_manager] | ||
file_filter = license_manager/conf/locale/<lang>/LC_MESSAGES/django.po | ||
source_file = license_manager/conf/locale/en/LC_MESSAGES/django.po | ||
[edx-platform.license-manager] | ||
file_filter = license-manager/conf/locale/<lang>/LC_MESSAGES/django.po | ||
source_file = license-manager/conf/locale/en/LC_MESSAGES/django.po | ||
source_lang = en | ||
type = PO | ||
|
||
[edx-platform.license_manager-js] | ||
file_filter = license_manager/conf/locale/<lang>/LC_MESSAGES/djangojs.po | ||
source_file = license_manager/conf/locale/en/LC_MESSAGES/djangojs.po | ||
[edx-platform.license-manager-js] | ||
file_filter = license-manager/conf/locale/<lang>/LC_MESSAGES/djangojs.po | ||
source_file = license-manager/conf/locale/en/LC_MESSAGES/djangojs.po | ||
source_lang = en | ||
type = PO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
FROM ubuntu:bionic as app | ||
MAINTAINER [email protected] | ||
|
||
|
||
# Packages installed: | ||
# git; Used to pull in particular requirements from github rather than pypi, | ||
# and to check the sha of the code checkout. | ||
|
||
# language-pack-en locales; ubuntu locale support so that system utilities have a consistent | ||
# language and time zone. | ||
|
||
# python; ubuntu doesnt ship with python, so this is the python we will use to run the application | ||
|
||
# python3-pip; install pip to install application requirements.txt files | ||
|
||
# libssl-dev; # mysqlclient wont install without this. | ||
|
||
# libmysqlclient-dev; to install header files needed to use native C implementation for | ||
# MySQL-python for performance gains. | ||
|
||
# If you add a package here please include a comment above describing what it is used for | ||
RUN apt-get update && apt-get upgrade -qy && apt-get install language-pack-en locales git python3.5 python3-pip libmysqlclient-dev libssl-dev python3-dev -qy && \ | ||
pip3 install --upgrade pip setuptools && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN ln -s /usr/bin/pip3 /usr/bin/pip | ||
RUN ln -s /usr/bin/python3 /usr/bin/python | ||
|
||
RUN locale-gen en_US.UTF-8 | ||
ENV LANG en_US.UTF-8 | ||
ENV LANGUAGE en_US:en | ||
ENV LC_ALL en_US.UTF-8 | ||
ENV DJANGO_SETTINGS_MODULE license_manager.settings.production | ||
|
||
EXPOSE 18170 | ||
RUN useradd -m --shell /bin/false app | ||
|
||
WORKDIR /edx/app/license_manager | ||
|
||
# Copy the requirements explicitly even though we copy everything below | ||
# this prevents the image cache from busting unless the dependencies have changed. | ||
COPY requirements/production.txt /edx/app/license_manager/requirements/production.txt | ||
|
||
# Dependencies are installed as root so they cannot be modified by the application user. | ||
RUN pip3 install -r requirements/production.txt | ||
|
||
RUN mkdir -p /edx/var/log | ||
|
||
# Code is owned by root so it cannot be modified by the application user. | ||
# So we copy it before changing users. | ||
USER app | ||
|
||
# Gunicorn 19 does not log to stdout or stderr by default. Once we are past gunicorn 19, the logging to STDOUT need not be specified. | ||
CMD gunicorn --workers=2 --name license_manager -c /edx/app/license_manager/license_manager/docker_gunicorn_configuration.py --log-file - --max-requests=1000 license_manager.wsgi:application | ||
|
||
# This line is after the requirements so that changes to the code will not | ||
# bust the image cache | ||
COPY . /edx/app/license_manager | ||
|
||
|
||
FROM app as newrelic | ||
RUN pip install newrelic | ||
CMD newrelic-admin run-program gunicorn --workers=2 --name license_manager -c /edx/app/license_manager/license_manager/docker_gunicorn_configuration.py --log-file - --max-requests=1000 license_manager.wsgi:application | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,65 +7,39 @@ below is executed within the virtualenv. | |
.. _virtualenv: https://virtualenvwrapper.readthedocs.org/en/latest/ | ||
|
||
|
||
Initialize and Provision | ||
------------------------ | ||
1. Start and provision the edX `devstack <https://github.com/edx/devstack>`_, as license-manager currently relies on devstack | ||
2. Verify that your virtual environment is active before proceeding | ||
3. Clone the license-manager repo and cd into that directory | ||
4. Run *make dev.provision* to provision a new license manager environment | ||
5. Run *make dev.init* to start the license manager app and run migrations | ||
|
||
Viewing License Manager | ||
------------------------ | ||
Once the server is up and running you can view the license manager at http://localhost:18170/admin. | ||
|
||
You can login with the username *[email protected]* and password *edx*. | ||
|
||
Makefile Commands | ||
The following is provided for informational purposes only. You can likely ignore this section. | ||
======= | ||
Install dependencies | ||
-------------------- | ||
The `Makefile <../Makefile>`_ includes numerous commands to start the service, but the basic commands are the following: | ||
|
||
Start the Docker containers to run the license manager servers | ||
|
||
.. code-block:: bash | ||
$ make dev.up | ||
Open the shell to the license manager container for manual commands | ||
|
||
.. code-block:: bash | ||
$ make app-shell | ||
Open the logs in the license manager container | ||
Dependencies can be installed via the command below. | ||
|
||
.. code-block:: bash | ||
$ make license-manager-logs | ||
$ make requirements | ||
Advanced Setup Outside Docker | ||
============================= | ||
The following is provided for informational purposes only. You can likely ignore this section. | ||
Local/Private Settings | ||
---------------------- | ||
When developing locally, it may be useful to have settings overrides that you do not wish to commit to the repository. | ||
If you need such overrides, create a file :file:`license_manager/settings/private.py`. This file's values are | ||
read by :file:`license_manager/settings/local.py`, but ignored by Git. | ||
If you need such overrides, create a file :file:`license-manager/settings/private.py`. This file's values are | ||
read by :file:`license-manager/settings/local.py`, but ignored by Git. | ||
|
||
Configure edX OAuth (Optional) | ||
------------------------------- | ||
|
||
OAuth only needs to be configured if the IDA would like to use the LMS's authentication functionality in place of managing its own. | ||
|
||
Configure edX OAuth | ||
------------------- | ||
This service relies on the LMS server as the OAuth 2.0 authentication provider. | ||
This functionality relies on the LMS server as the OAuth 2.0 authentication provider. | ||
|
||
Configuring License Manager service to communicate with other IDAs using OAuth requires registering a new client with the authentication | ||
Configuring License Manager to communicate with other IDAs using OAuth requires registering a new client with the authentication | ||
provider (LMS) and updating the Django settings for this project with the generated client credentials. | ||
|
||
A new OAuth 2.0 client can be created when using Devstack by visiting ``http://127.0.0.1:18000/admin/oauth2_provider/application/``. | ||
1. Click the :guilabel:`Add Application` button. | ||
2. Leave the user field blank. | ||
3. Specify the name of this service, ``License Manager service``, as the client name. | ||
4. Set the :guilabel:`URL` to the root path of this service: ``http://127.0.0.1:8003/``. | ||
5. Set the :guilabel:`Redirect URL` to the complete endpoint: ``http://127.0.0.1:18150/complete/edx-oauth2/``. | ||
3. Specify the name of this service, ``License Manager``, as the client name. | ||
4. Set the :guilabel:`URL` to the root path of this service: ``http://127.0.0.1:18170/``. | ||
5. Set the :guilabel:`Redirect URL` to the complete endpoint: ``http://127.0.0.1:18170/complete/edx-oauth2/``. | ||
6. Copy the :guilabel:`Client ID` and :guilabel:`Client Secret` values. They will be used later. | ||
7. Select :guilabel:`Confidential` as the client type. | ||
8. Select :guilabel:`Authorization code` as the authorization grant type. | ||
|
@@ -74,7 +48,7 @@ A new OAuth 2.0 client can be created when using Devstack by visiting ``http://1 | |
|
||
|
||
Now that you have the client credentials, you can update your settings (ideally in | ||
:file:`license_manager/settings/local.py`). The table below describes the relevant settings. | ||
:file:`license-manager/settings/local.py`). The table below describes the relevant settings. | ||
|
||
+-----------------------------------+----------------------------------+--------------------------------------------------------------------------+ | ||
| Setting | Description | Value | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
""" | ||
gunicorn configuration file: http://docs.gunicorn.org/en/develop/configure.html | ||
""" | ||
import multiprocessing # pylint: disable=unused-import | ||
|
||
|
||
preload_app = True | ||
timeout = 300 | ||
bind = "0.0.0.0:18170" | ||
|
||
workers = 2 | ||
|
||
|
||
def pre_request(worker, req): | ||
worker.log.info("%s %s" % (req.method, req.path)) | ||
|
||
|
||
def close_all_caches(): | ||
""" | ||
Close the cache so that newly forked workers cannot accidentally share | ||
the socket with the processes they were forked from. This prevents a race | ||
condition in which one worker could get a cache response intended for | ||
another worker. | ||
""" | ||
# We do this in a way that is safe for 1.4 and 1.8 while we still have some | ||
# 1.4 installations. | ||
from django.conf import settings | ||
from django.core import cache as django_cache | ||
if hasattr(django_cache, 'caches'): | ||
get_cache = django_cache.caches.__getitem__ | ||
else: | ||
get_cache = django_cache.get_cache # pylint: disable=no-member | ||
for cache_name in settings.CACHES: | ||
cache = get_cache(cache_name) | ||
if hasattr(cache, 'close'): | ||
cache.close() | ||
|
||
# The 1.4 global default cache object needs to be closed also: 1.4 | ||
# doesn't ensure you get the same object when requesting the same | ||
# cache. The global default is a separate Python object from the cache | ||
# you get with get_cache("default"), so it will have its own connection | ||
# that needs to be closed. | ||
cache = django_cache.cache | ||
if hasattr(cache, 'close'): | ||
cache.close() | ||
|
||
|
||
def post_fork(server, worker): # pylint: disable=unused-argument | ||
close_all_caches() | ||
|
||
def when_ready(server): # pylint: disable=unused-argument | ||
"""When running in debug mode, run Django's `check` to better match what `manage.py runserver` does""" | ||
from django.conf import settings | ||
from django.core.management import call_command | ||
if settings.DEBUG: | ||
call_command("check") |
Oops, something went wrong.