Skip to content

Commit

Permalink
Merge pull request #686 from zurdi15/release
Browse files Browse the repository at this point in the history
Merge 'release' into 'master'
  • Loading branch information
zurdi15 committed Mar 12, 2024
2 parents c789c42 + c6771b6 commit 9d2f728
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ backend/romm_test/resources
backend/romm_test/logs
backend/romm_test/config
.pytest_cache
/romm_test

# service worker
frontend/dev-dist
Expand Down
26 changes: 9 additions & 17 deletions backend/endpoints/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,27 @@
router = APIRouter()


@protected_route(router.post, "/tasks", ["tasks.run"])
async def run_tasks(request: Request, action: str) -> MessageResponse:
@protected_route(router.post, "/tasks/run", ["tasks.run"])
async def run_tasks(request: Request) -> MessageResponse:
"""Run all tasks endpoint
Args:
request (Request): Fastapi Request object
action: Action to perform on tasks
Returns:
RunTasksResponse: Standard message response
"""

if action == "run":
await update_mame_xml_task.run()
await update_switch_titledb_task.run()
return {"msg": f"All tasks {action} successfully!"}

return {"msg": "No action performed on tasks"}
await update_mame_xml_task.run()
await update_switch_titledb_task.run()
return {"msg": "All tasks ran successfully!"}


@protected_route(router.post, "/tasks/{task}", ["tasks.run"])
async def run_task(request: Request, task: str, action: str) -> MessageResponse:
@protected_route(router.post, "/tasks/{task}/run", ["tasks.run"])
async def run_task(request: Request, task: str) -> MessageResponse:
"""Run all tasks endpoint
Args:
request (Request): Fastapi Request object
action: Action to perform on tasks
Returns:
RunTasksResponse: Standard message response
"""
Expand All @@ -42,8 +37,5 @@ async def run_task(request: Request, task: str, action: str) -> MessageResponse:
"switch_titledb": update_switch_titledb_task
}

if action == "run":
await tasks[task].run()
return {"msg": f"Task {task} {action} successfully!"}

return {"msg": "No action performed on task {task}"}
await tasks[task].run()
return {"msg": f"Task {task} run successfully!"}
7 changes: 4 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ RUN wget -O redis.tar.gz "$REDIS_DOWNLOAD_URL"; \
redis-server --version; \
echo '{"spdxVersion":"SPDX-2.3","SPDXID":"SPDXRef-DOCUMENT","name":"redis-server-sbom","packages":[{"name":"redis-server","versionInfo":"7.2.4","SPDXID":"SPDXRef-Package--redis-server","externalRefs":[{"referenceCategory":"PACKAGE-MANAGER","referenceType":"purl","referenceLocator":"pkg:generic/redis-server@7.2.4?os_name=alpine&os_version=3.19"}],"licenseDeclared":"BSD-3-Clause"}]}' > /usr/local/redis.spdx.json

RUN mkdir /redis-data && chown 1000:1000 /redis-data
VOLUME /redis-data

# cleanup additional build dependencies
RUN apk del \
gcc \
Expand Down Expand Up @@ -157,6 +154,10 @@ COPY --from=production-stage / /
RUN addgroup -g 1000 -S romm && adduser -u 1000 -D -S -G romm romm
RUN mkdir /romm && chown 1000:1000 /romm -R

# Create data volume for redis
RUN mkdir /redis-data && chown 1000:1000 /redis-data
VOLUME /redis-data

# Expose ports and start
EXPOSE 8080
EXPOSE 6379/tcp
Expand Down
2 changes: 1 addition & 1 deletion docker/init_scripts/init
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ start_bin_redis-server () {
if [ -f /usr/local/etc/redis/redis.conf ]; then
redis-server /usr/local/etc/redis/redis.conf &
else
redis-server &
redis-server --dir /redis-data &
fi
REDIS_PID=$!
echo $REDIS_PID > /tmp/redis-server.pid
Expand Down
1 change: 1 addition & 0 deletions examples/docker-compose.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ services:
- ROMM_AUTH_PASSWORD= # default: admin
volumes:
- romm_resources:/romm/resources # Resources fetched from IGDB (covers, screenshots, etc.)
- romm_redis_data:/redis-data # Cached data for background tasks
- /path/to/library:/romm/library # Your game library
- /path/to/assets:/romm/assets # Uploaded saves, states, etc.
- /path/to/config:/romm/config # [Optional] Path where config.yml is stored
Expand Down

0 comments on commit 9d2f728

Please sign in to comment.