Skip to content

Commit

Permalink
Merge branch 'develop' into gevent_timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
varmar05 committed Oct 31, 2024
2 parents 4289874 + b0d4be8 commit 06c3f15
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 32 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/auto_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ jobs:
- name: Run tests
run: |
cd server
pipenv run pytest -v --cov=mergin mergin/tests
pipenv run pytest -v --cov=mergin --cov-report=lcov mergin/tests
# - name: Coveralls
# uses: coverallsapp/github-action@v2
# with:
# base-path: server
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
base-path: server
format: lcov
17 changes: 12 additions & 5 deletions .prod.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ LOCAL_PROJECTS=/data
#MAINTENANCE_FILE=os.path.join(LOCAL_PROJECTS, 'MAINTENANCE') # locking file when backups are created
MAINTENANCE_FILE=/data/MAINTENANCE

#PROXY_FIX=True

#PUBLIC_DIR=os.path.join(config_dir, os.pardir, 'build', 'static')

#SECRET_KEY=NODEFAULT
SECRET_KEY=fixme

Expand Down Expand Up @@ -110,7 +106,11 @@ MAIL_USERNAME=fixme
#MAX_DOWNLOAD_ARCHIVE_SIZE=1024 * 1024 * 1024 # max total files size for archive download

#USE_X_ACCEL=False # use nginx (in front of gunicorn) to serve files (https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/)
USE_X_ACCEL=1

# where geodiff lib copies working files
#GEODIFF_WORKING_DIR=$LOCAL_PROJECTS/geodiff_tmp
GEODIFF_WORKING_DIR=/data/geodiff

# celery

Expand All @@ -133,6 +133,8 @@ CELERYD_CONCURRENCY=2

#CELERYD_PREFETCH_MULTIPLIER=4

#CELERY_ROUTES={} # split tasks into separate queues

# various life times

#CLOSED_ACCOUNT_EXPIRATION=5 # time in days after user closed his account to all projects and files are permanently deleted
Expand Down Expand Up @@ -167,8 +169,13 @@ GLOBAL_STORAGE=10737418240

# GLOBAL_ADMIN False

# Gunicorn server socket
# toggle registration form to create new users
#USER_SELF_REGISTRATION=False

# what type of server is running, e.g. community edition or enterprise edition
#SERVER_TYPE=ce

# Gunicorn server socket
PORT=5000

GEVENT_WORKER=True
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ services:
user: 901:999
volumes:
- ./projects:/data
- ./server/entrypoint.sh:/app/entrypoint.sh
env_file:
- .prod.env
depends_on:
Expand All @@ -38,8 +39,11 @@ services:
celery-beat:
image: lutraconsulting/merginmaps-backend:2024.2.2
container_name: celery-beat
restart: always
env_file:
- .prod.env
volumes:
- ./server/entrypoint.sh:/app/entrypoint.sh
depends_on:
- redis
- server-gunicorn
Expand All @@ -49,8 +53,13 @@ services:
celery-worker:
image: lutraconsulting/merginmaps-backend:2024.2.2
container_name: celery-worker
restart: always
user: 901:999
env_file:
- .prod.env
volumes:
- ./projects:/data
- ./server/entrypoint.sh:/app/entrypoint.sh
depends_on:
- redis
- server-gunicorn
Expand All @@ -72,6 +81,8 @@ services:
image: nginxinc/nginx-unprivileged:1.25.5
container_name: merginmaps-proxy
restart: always
# run nginx as built-in user but with group mergin-family for files permissions
user: 101:999
ports:
- "8080:8080"
volumes:
Expand Down
2 changes: 1 addition & 1 deletion nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ server {

location /download/ {
internal;
alias /data; # we need to mount data from mergin server here
alias /data/; # we need to mount data from mergin server here
}
}
25 changes: 11 additions & 14 deletions server/mergin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@


class Configuration(object):
# flask/connexion variables
DEBUG = config("FLASK_DEBUG", default=False, cast=bool)
TESTING = config("TESTING", default=False, cast=bool)
SECRET_KEY = config("SECRET_KEY")
PROXY_FIX = config("PROXY_FIX", default=True, cast=bool)
SWAGGER_UI = config(
"SWAGGER_UI", default=False, cast=bool
) # to enable swagger UI console (for tests only)
VERSION = config("VERSION", default=get_version())
PUBLIC_DIR = config(
"PUBLIC_DIR", default=os.path.join(config_dir, os.pardir, "build", "static")
)
# to enable swagger UI console (for tests only)
SWAGGER_UI = config("SWAGGER_UI", default=False, cast=bool)
# expiration time in seconds
WTF_CSRF_TIME_LIMIT = config("WTF_CSRF_TIME_LIMIT", default=3600 * 24, cast=int)
WTF_CSRF_ENABLED = config("WTF_CSRF_ENABLED", default=True, cast=bool)

# Mergin DB related
SQLALCHEMY_TRACK_MODIFICATIONS = config(
Expand All @@ -43,11 +41,6 @@ class Configuration(object):
f"postgresql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_DATABASE}?application_name={DB_APPLICATION_NAME}",
)

WTF_CSRF_TIME_LIMIT = config(
"WTF_CSRF_TIME_LIMIT", default=3600 * 24, cast=int
) # in seconds
WTF_CSRF_ENABLED = config("WTF_CSRF_ENABLED", default=True, cast=bool)

# for flask mail
MAIL_SERVER = config("MAIL_SERVER", default="localhost")
MAIL_PORT = config("MAIL_PORT", default=587, cast=int)
Expand Down Expand Up @@ -97,12 +90,16 @@ class Configuration(object):
GLOBAL_WRITE = config("GLOBAL_WRITE", default=False, cast=bool)
GLOBAL_ADMIN = config("GLOBAL_ADMIN", default=False, cast=bool)

SERVER_TYPE = config("SERVER_TYPE", default="")
# can users create their own account or is it reserved for superuser only
USER_SELF_REGISTRATION = config("USER_SELF_REGISTRATION", default=False, cast=bool)

# build hash number
BUILD_HASH = config("BUILD_HASH", default="")

# backend version
VERSION = config("VERSION", default=get_version())
SERVER_TYPE = config("SERVER_TYPE", default="ce")

# whether to run flask app with gevent worker type in gunicorn
# using gevent type of worker impose some requirements on code, e.g. to be greenlet safe, custom timeouts
GEVENT_WORKER = config("GEVENT_WORKER", default=False, cast=bool)
Expand Down
8 changes: 4 additions & 4 deletions server/mergin/sync/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ def download(project_name, version, directory): # pylint: disable=W0612
os.mkdir(directory)
files = pv.files
for f in files:
project.storage.restore_versioned_file(f["path"], version)
f_dir = os.path.dirname(f["path"])
project.storage.restore_versioned_file(f.path, version)
f_dir = os.path.dirname(f.path)
if f_dir:
os.makedirs(os.path.join(directory, f_dir), exist_ok=True)
shutil.copy(
os.path.join(project.storage.project_dir, f["location"]),
os.path.join(directory, f["path"]),
os.path.join(project.storage.project_dir, f.location),
os.path.join(directory, f.path),
)
print("Project downloaded successfully")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-MerginMaps-Commercial
}"
>
<template v-if="showNamespace"
>{{ slotProps.data.namespace }} /</template
>{{ slotProps.data.namespace }} / </template
>{{ slotProps.data.name }}</router-link
><PTag
v-if="slotProps.data.access.public && !onlyPublic"
Expand Down Expand Up @@ -187,7 +187,7 @@ export default defineComponent({
columns = columns.concat(
{ header: 'Project name', field: 'name' },
{ header: 'Versions', field: 'version' },
{ header: 'Size', field: 'meta.size' },
{ header: 'Size', field: 'meta.size' }
// {
// header: 'Collaborators',
// field: 'access.readers'
Expand Down
9 changes: 9 additions & 0 deletions web-app/packages/lib/src/modules/project/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const useProjectStore = defineStore('projectModule', {
},

setProject(payload: { project: ProjectDetail }) {
const userStore = useUserStore()
let enhancedProject: EnhancedProjectDetail = null
if (payload.project) {
enhancedProject = {
Expand All @@ -147,6 +148,14 @@ export const useProjectStore = defineStore('projectModule', {
}
}
this.project = enhancedProject

// Update workspace
if (enhancedProject) {
userStore.setWorkspace({
workspaceId: enhancedProject?.workspace_id,
skipStorage: false
})
}
},
setProjects(payload: ProjectsPayload) {
this.projects = payload.projects
Expand Down
2 changes: 1 addition & 1 deletion web-app/packages/lib/src/modules/user/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const useUserStore = defineStore('userModule', {
this.workspaces = payload.workspaces
},

setWorkspaceId(payload) {
setWorkspaceId(payload: { id: number }) {
this.workspaceId = payload.id
},

Expand Down

0 comments on commit 06c3f15

Please sign in to comment.