fix start and install bat
This commit is contained in:
@@ -17,7 +17,7 @@ Node.js 18 and 20 are not supported by the current native SQLite dependency.
|
||||
2. Double-click `windows\install.bat`.
|
||||
3. Approve the Node.js LTS installation if Windows asks for it.
|
||||
4. Wait until the script reports `Windows setup completed`.
|
||||
5. Start with `windows\start_backend.bat` or `npm start`.
|
||||
5. The installer runs `npm.cmd restart`, leaving the backend running in the background.
|
||||
6. Open `http://localhost:8081`.
|
||||
|
||||
The installer:
|
||||
@@ -25,11 +25,12 @@ The installer:
|
||||
- checks the Windows architecture
|
||||
- checks Node.js and installs current LTS with `winget` when needed
|
||||
- installs/checks Microsoft Visual C++ 2015-2022 x64 Runtime for bundled AMMC
|
||||
- runs `npm ci` from `package-lock.json`
|
||||
- runs `npm.cmd ci` from `package-lock.json`
|
||||
- verifies that Express loads
|
||||
- opens an in-memory SQLite database through `better-sqlite3`
|
||||
- verifies `ammc-amb.exe`, `ammc.dll`, and `MyLapsSDK.dll`
|
||||
- creates `data\` and `logs\`
|
||||
- runs `npm.cmd restart` so both new installations and updates use the installed code immediately
|
||||
|
||||
Run from PowerShell instead when you want options:
|
||||
|
||||
@@ -54,9 +55,9 @@ npm.cmd run verify
|
||||
npm.cmd start
|
||||
```
|
||||
|
||||
`npm ci` installs exactly the dependency versions in `package-lock.json`. The install fails early with an actionable message if Node.js is unsupported. The post-install verification also fails if the native SQLite module cannot run.
|
||||
`npm.cmd ci` installs exactly the dependency versions in `package-lock.json`. The install fails early with an actionable message if Node.js is unsupported. The post-install verification also fails if the native SQLite module cannot run.
|
||||
|
||||
The project intentionally uses `better-sqlite3` v12.11.x. That release provides a working prebuilt Windows binary for the supported Node.js versions. The package is explicitly listed in `allowScripts` so npm 12 may run its binary installer; do not use `npm ci --ignore-scripts`.
|
||||
The project intentionally uses `better-sqlite3` v12.11.x. That release provides a working prebuilt Windows binary for the supported Node.js versions. The package is explicitly listed in `allowScripts` so npm 12 may run its binary installer; do not use `npm.cmd ci --ignore-scripts`.
|
||||
|
||||
Use `npm.cmd` from PowerShell when local execution policy blocks `npm.ps1`. The plain `npm` command works normally from Command Prompt (`cmd.exe`).
|
||||
|
||||
@@ -70,19 +71,20 @@ npm.cmd stop
|
||||
npm.cmd run start:fg
|
||||
```
|
||||
|
||||
- `npm start` starts `server.js` in the background.
|
||||
- `npm run status` reads `data\server.pid` and reports process state.
|
||||
- `npm restart` restarts the background process.
|
||||
- `npm stop` stops it.
|
||||
- `npm run start:fg` runs in the current terminal for troubleshooting.
|
||||
- `npm.cmd start` starts `server.js` in the background.
|
||||
- `npm.cmd run status` reads `data\server.pid` and reports process state.
|
||||
- `npm.cmd restart` restarts the background process.
|
||||
- `npm.cmd stop` stops it.
|
||||
- `npm.cmd run start:fg` runs in the current terminal for troubleshooting.
|
||||
- stdout is written to `logs\server.out.log`.
|
||||
- stderr is written to `logs\server.err.log`.
|
||||
- SQLite data is written to `data\rc_timing.sqlite`.
|
||||
|
||||
## Windows helper scripts
|
||||
|
||||
- `windows\install.bat`: install and verify all runtime dependencies
|
||||
- `windows\install.bat`: install, verify, and restart the backend
|
||||
- `windows\start_backend.bat`: start the Node backend in the background
|
||||
- `windows\restart_backend.bat`: restart the Node backend after copied or pulled updates
|
||||
- `windows\start_ammc.bat`: start bundled AMMC manually
|
||||
- `windows\start_all.bat`: start AMMC, backend, and open the browser
|
||||
- `windows\stop_all.bat`: stop the backend and `ammc-amb.exe`
|
||||
@@ -111,14 +113,14 @@ windows\start_ammc.bat
|
||||
|
||||
The recommended normal operation is to let the backend manage AMMC:
|
||||
|
||||
1. Start RaceController with `npm start`.
|
||||
1. Start RaceController with `npm.cmd start`.
|
||||
2. Open `Settings`.
|
||||
3. Enable `Managed AMMC`.
|
||||
4. Set the decoder IP and WebSocket port `9000`.
|
||||
5. Save and click `Start AMMC`.
|
||||
6. Use the server WebSocket URL and connect the decoder.
|
||||
|
||||
AMMC always runs on the computer that runs `npm start`. Opening the UI from a laptop does not start AMMC on that laptop.
|
||||
AMMC always runs on the computer that runs `npm.cmd start`. Opening the UI from a laptop does not start AMMC on that laptop.
|
||||
|
||||
## Network access
|
||||
|
||||
@@ -167,7 +169,7 @@ npm.cmd stop
|
||||
git pull
|
||||
npm.cmd ci
|
||||
npm.cmd run verify
|
||||
npm.cmd start
|
||||
npm.cmd restart
|
||||
```
|
||||
|
||||
Keep `data\` when updating. It contains the SQLite database, saved state, PID file, and local AMMC configuration.
|
||||
|
||||
@@ -4,7 +4,8 @@ setlocal
|
||||
echo JMK RB RaceController - Windows 11 setup
|
||||
echo.
|
||||
|
||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0setup.ps1" %*
|
||||
rem setup.ps1 refreshes PATH after a Node installation and runs npm.cmd restart.
|
||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0setup.ps1" -StartServer %*
|
||||
set "EXIT_CODE=%ERRORLEVEL%"
|
||||
|
||||
echo.
|
||||
|
||||
24
windows/restart_backend.bat
Normal file
24
windows/restart_backend.bat
Normal file
@@ -0,0 +1,24 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
for %%I in ("%~dp0..") do set "APP_DIR=%%~fI"
|
||||
where node.exe >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Node.js was not found. Run windows\install.bat first.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
pushd "%APP_DIR%"
|
||||
call npm.cmd restart
|
||||
set "EXIT_CODE=%ERRORLEVEL%"
|
||||
popd
|
||||
|
||||
if not "%EXIT_CODE%"=="0" (
|
||||
echo [ERROR] Backend restart failed.
|
||||
exit /b %EXIT_CODE%
|
||||
)
|
||||
|
||||
echo [OK] Backend restarted in background
|
||||
echo URL: http://localhost:8081
|
||||
echo Logs: %APP_DIR%\logs\server.out.log
|
||||
endlocal
|
||||
@@ -128,16 +128,17 @@ if ($OpenFirewall) {
|
||||
}
|
||||
|
||||
if ($StartServer) {
|
||||
Write-Step "Starting RaceController"
|
||||
& $npmCommand start
|
||||
Write-Step "Restarting RaceController after installation"
|
||||
& $npmCommand restart
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "RaceController did not start (exit code $LASTEXITCODE)."
|
||||
throw "RaceController did not restart (exit code $LASTEXITCODE)."
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Windows setup completed." -ForegroundColor Green
|
||||
Write-Host "Start: npm start"
|
||||
Write-Host "Status: npm run status"
|
||||
Write-Host "Stop: npm stop"
|
||||
Write-Host "Start: npm.cmd start"
|
||||
Write-Host "Restart: npm.cmd restart"
|
||||
Write-Host "Status: npm.cmd run status"
|
||||
Write-Host "Stop: npm.cmd stop"
|
||||
Write-Host "Open: http://localhost:8081"
|
||||
|
||||
Reference in New Issue
Block a user