Install on Windows#
The Windows service runs on CrushMFT's own service launcher, the one CrushMFT 27 and CrushTunnel use: -i writes service\CrushBalanceService.exe (the launcher) and service\CrushBalanceService.conf, and the launcher runs CrushBalance.jar -d as the service "CrushBalance Server". The jar picks the engine from prefs.XML.
- Create an install folder that only administrators can write to, for example
C:\Program Files\CrushBalance(a folder, not the root of a drive), and copyCrushBalance.jarinto it. Install Java where only administrators can write too (the Java installers' default underC:\Program Filesis such a folder). - Open a Command Prompt in the install folder and run
java -jar CrushBalance.jar -i [heapMB]heapMBis the Java heap in MB (128–65536, default 1024).-imust be run from the folder that contains the jar. The launcher asks for administrator rights itself, with one UAC prompt.-iwrites theservice\files itself, so in a folder that needs elevation to write (such as one underC:\Program Files) run it from an elevated Command Prompt ("Run as administrator"). The service always uses the install folder as its prefs directory;-Dcrushbalance.prefsdoes not reach it.
- What
-idoes:- checks the folder before it writes anything (the refusals below);
- checks that ordinary users cannot write to the folder,
service\or the jar (the service runs as SYSTEM and runs that jar), and warns when they can read the folder; - writes
service\CrushBalanceService.exeandservice\CrushBalanceService.conf(UTF-8key=valuelines). An existing conf is kept:-isets onlyservice_name,display_name,working_dir,jarand, when you pass a heap or the key is missing,memory; your other edits stay.memoryalso takes a percentage of the machine's RAM (memory=60%). Restart the service to apply a change made by hand; - installs and starts the service through the launcher (
install start); a running service is updated and restarted (install restart); - waits until the service has been running for 3 seconds (two checks of its state at least 3 s apart, within 30 s of the start), and then reports
Service "CrushBalance Server" installed and running (heap …).(or… updated and restarted.); - on a failure, prints the reason and then the last 20 lines of
service\wrapper.log, with exit code 4. A service that stops again right after its start (for example because a CrushBalance started by hand in a console holds the folder) is a failure too:the service "CrushBalance Server" was not running for 3 s in a row within 30 s after the start (state 4)., orthe service "CrushBalance Server" is not running 30 s after the start (state …).
- Administrator approval. When the UAC prompt is declined, or cannot be shown (no desktop, for example over SSH),
-istops with exit code 4:Administrator approval was declined, or it could not be asked (no desktop, for example in an SSH session). Run this command from an elevated Command Prompt ("Run as administrator"). - The setup token is in
service\wrapper.log(with the admin URL and the certificate fingerprint) and insetup-token.txtin the install folder. Continue with First-run setup. - Refusals before anything is written (exit code 4):
- not started from the jar's folder:
Run -i from the folder that contains CrushBalance.jar; - the root of a drive or share:
Install CrushBalance into a folder, not the root of a drive (E:\).(theicaclsfix below would rewrite the whole drive); - a
service\folder this prompt cannot write:… cannot be written from this Command Prompt. Run this command from an elevated Command Prompt ("Run as administrator").; - the folder check below.
- not started from the jar's folder:
- If the folder check refuses:
-istops with exit code 4:CrushBalance: <dir> can be written by Everyone, Authenticated Users or Users, so any local user could make the service run their code as SYSTEM., the offending entries,To remove that access, run from an elevated Command Prompt:and the fix, two commands to run on the folder, thenA folder under C:\Program Files is protected already.:
(the first stops inheriting rights from the parent folder, the second removes the rights of Everyone, Authenticated Users and Users on the folder and everything in it).icacls "<dir>" /inheritance:d icacls "<dir>" /remove:g *S-1-1-0 *S-1-5-11 *S-1-5-32-545 /T- To install anyway, run
java -Dcrushbalance.service.allow_writable_dir=true -jar CrushBalance.jar -i; the refusal becomes a warning (CrushBalance: WARN: …; installing anyway because -Dcrushbalance.service.allow_writable_dir=true.). Do this only when nobody else can log on to the host.
- To install anyway, run
- A warning when ordinary users can read the folder. The install goes on, with
CrushBalance: WARN: <dir> can be read by Everyone, Authenticated Users or Users, and prefs.XML there, with the registration code and the admin password verifier, inherits that access., the entries,To remove that access, run from an elevated Command Prompt:and the same twoicaclscommands. Run them to keepprefs.XMLprivate (Hardening: What is sensitive). - Which Java the service runs is the launcher's choice, not the Java that ran
-i; keep that Java where only administrators can write (Hardening: The Windows service). - One service per host. Run
-iand-rin the folder the service was installed from. - Run the other commands from an elevated prompt too (
-set-admin-password,-check-config,-r), in the install folder. In a protected folder a non-elevated prompt can neither writeprefs.XMLnor readcrushbalance.key, whose access list admits only its owner, SYSTEM and Administrators (-check-configthen reports KEY_UNUSABLE). - Start and stop:
net start "CrushBalance Server",net stop "CrushBalance Server", or the Services console. The launcher stops CrushBalance by closing its standard input; it then drains open connections for at most 3 seconds and ends after about 4. - Change the heap: run
-i heapMBagain in the install folder, or editmemory=inservice\CrushBalanceService.confand restart the service. - Remove the service with
java -jar CrushBalance.jar -rin the install folder. The launcher uninstalls the service (one UAC prompt);-rthen deletes the launcher and the conf.service\wrapper.logis kept. - The web UI never installs or removes the service; System › Windows service only shows the state and the commands.