Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions backend/run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@echo off
REM Windows batch script for running PictoPy backend

echo Starting backend server...

REM Start the backend server with Hypercorn
cd /d "%~dp0"

if "%1"=="--test" (
echo Starting Hypercorn server in test environment...
hypercorn main:app --bind 0.0.0.0:8000 --log-level debug --reload --access-log -
) else (
REM Print the value of the WORKERS environment variable
echo WORKERS: %WORKERS%
if not defined WORKERS (
hypercorn main:app --workers 1 --bind 0.0.0.0:8000
) else (
hypercorn main:app --workers %WORKERS% --bind 0.0.0.0:8000
)
)
Comment on lines +12 to +20
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat backend/run.bat

Repository: AOSSIE-Org/PictoPy

Length of output: 653


🏁 Script executed:

cat backend/run.sh

Repository: AOSSIE-Org/PictoPy

Length of output: 852


Fix inconsistent WORKERS handling between scripts.

The run.bat and run.sh scripts behave differently when WORKERS is defined but empty. The batch script will pass an empty value to hypercorn, while the bash script correctly defaults to 1 (due to ${WORKERS:-1}). Update run.bat to match bash behavior by handling the empty case:

Fix: Handle undefined and empty WORKERS
 ) else (
     REM Print the value of the WORKERS environment variable
     echo WORKERS: %WORKERS%
-    if not defined WORKERS (
+    if not defined WORKERS (
+        set "WORKERS=1"
+    )
+    if "%WORKERS%"=="" (
         set "WORKERS=1"
     )
-    ) else (
-        hypercorn main:app --workers %WORKERS% --bind 0.0.0.0:8000
-    )
+    hypercorn main:app --workers %WORKERS% --bind 0.0.0.0:8000
 )

As an optional defensive improvement, both scripts could validate that WORKERS is a positive integer, though this is not critical since the value is typically controlled by the deployment environment.

🤖 Prompt for AI Agents
In @backend/run.bat around lines 12 - 20, The batch script's WORKERS handling
passes an empty value to hypercorn; update the run.bat logic around the WORKERS
check so that both undefined and empty WORKERS default to 1 before calling
hypercorn (e.g., test "%WORKERS%"=="" or set a default variable when not
defined/empty) and then invoke hypercorn main:app with the resolved worker count
instead of passing a possibly-empty %WORKERS% directly.

Empty file modified backend/run.sh
100644 → 100755
Empty file.
329 changes: 328 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "concurrently --kill-others-on-fail --names \"BACKEND,FRONTEND\" --prefix-colors \"blue,magenta\" \"npm run backend\" \"npm run frontend\"",
"backend": "run-script-os",
"backend:win32": "cd backend && run.bat",
"backend:darwin:linux": "cd backend && ./run.sh",
"frontend": "cd frontend && npm run tauri dev",
Comment thread
coderabbitai[bot] marked this conversation as resolved.
"linux-dev": "bash ./scripts/linux-dev.sh",
"win-dev": "cd scripts && win-dev.bat",
"prepare": "husky",
Expand All @@ -15,6 +20,8 @@
"setup": "cd scripts && node setup.js"
},
"devDependencies": {
"husky": "^9.1.7"
"concurrently": "^9.2.1",
"husky": "^9.1.7",
"run-script-os": "^1.1.6"
}
}
}