Skip to content

Commit

Permalink
Merge pull request #461 from opengisch/release_patch
Browse files Browse the repository at this point in the history
  • Loading branch information
suricactus authored Dec 17, 2022
2 parents ec593d7 + bb1d5cb commit 4753720
Show file tree
Hide file tree
Showing 26 changed files with 495 additions and 186 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ QFIELDCLOUD_ADMIN_URI=admin/
# QFieldCloud URL used within the worker as configuration for qfieldcloud-sdk
QFIELDCLOUD_WORKER_QFIELDCLOUD_URL=http://app:8000/api/v1/

# number of parallel workers
# DEFAULT: 1
QFIELDCLOUD_WORKER_REPLICAS=1

# The Django development port. Not used in production.
# DEFAULT: 8011
DJANGO_DEV_PORT=8011
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ jobs:
- name: Build and run docker containers
run: |
docker-compose up -d --build
- name: Migrate
- name: Initial manage.py commands
run: |
docker-compose run app python manage.py migrate
docker-compose run app python manage.py collectstatic
- name: Run unit and integration tests
run: |
docker-compose run app python manage.py test --keepdb -v2 qfieldcloud
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ repos:
- id: black

# Lint files
- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/pycqa/flake8
rev: "3.9.0"
hooks:
- id: flake8
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ Docker logs are managed by docker in the default way. To read the logs:
docker-compose logs


For great `nginx` logs, use:

QFC_JQ='[.ts, .ip, (.method + " " + (.status|tostring) + " " + (.resp_time|tostring) + "s"), .uri, "I " + (.request_length|tostring) + " O " + (.resp_body_size|tostring), "C " + (.upstream_connect_time|tostring) + "s", "H " + (.upstream_header_time|tostring) + "s", "R " + (.upstream_response_time|tostring) + "s", .user_agent] | @tsv'
docker compose logs nginx -f --no-log-prefix | grep ':"nginx"' | jq -r $QFC_JQ


### Geodb

The geodb (database for the users projects data) is installed on
Expand Down
34 changes: 29 additions & 5 deletions conf/nginx/templates/default.conf.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
log_format upstreamlog '[$time_local] $remote_addr - $remote_user '
'to: $upstream_addr "$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"'
'rt=$request_time uct="$upstream_connect_time" uht="$upstream_header_time" urt="$upstream_response_time"';
map "$time_iso8601 # $msec" $time_iso8601_ms {
"~([^+]+)\+([\d:]+?) # \d+?\.(\d+)" "$1.$3+$2";
}

log_format json-logger escape=json
'{'
'"ts":"$time_iso8601_ms",'
'"ip":"$remote_addr",'
'"method":"$request_method",'
'"status":$status,'
'"resp_time":$request_time,'
'"request_length":$request_length,'
'"resp_body_size":$body_bytes_sent,'
'"uri":"$request_uri",'
'"connection": "$connection",'
'"connection_requests": "$connection_requests",'
'"user_agent":"$http_user_agent",'
'"host":"$http_host",'
'"user":"$remote_user",'
'"upstream_addr":"$upstream_addr",'
'"upstream_connect_time":"$upstream_connect_time",'
'"upstream_header_time":"$upstream_header_time",'
'"upstream_response_time":"$upstream_response_time",'
'"source":"nginx"'
'}';



upstream django {
server app:8000 fail_timeout=0;
Expand Down Expand Up @@ -33,6 +56,8 @@ server {
ssl_certificate certs/${QFIELDCLOUD_HOST}.pem;
ssl_certificate_key certs/${QFIELDCLOUD_HOST}-key.pem;

access_log /var/log/nginx/access.log json-logger;

server_name ${QFIELDCLOUD_HOST};
client_max_body_size 10G;
keepalive_timeout 5;
Expand Down Expand Up @@ -85,7 +110,6 @@ server {
# Only allow internal redirects
internal;

access_log /var/log/nginx/access.log upstreamlog;
set $redirect_uri "$upstream_http_redirect_uri";

# required DNS
Expand Down
20 changes: 20 additions & 0 deletions docker-app/qfieldcloud/authentication/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.contrib import admin
from django.contrib.admin import register

from .models import AuthToken


@register(AuthToken)
class AuthTokenAdmin(admin.ModelAdmin):
list_display = ("user", "created_at", "expires_at", "last_used_at", "client_type")
readonly_fields = (
"key",
"user",
"created_at",
"last_used_at",
"client_type",
"user_agent",
)
list_filter = ("created_at", "last_used_at", "expires_at")

search_fields = ("user__username__iexact", "client_type", "key__startswith")
Loading

0 comments on commit 4753720

Please sign in to comment.