@@ -109,82 +109,35 @@ Moqui code. The server must be started by the agent, and implementations should
109109be tested iteratively by calling services/querying entities and monitoring
110110server output until the code truly works.
111111
112- ### Initial Setup and Server Start
112+ ### Server Management
113113
114- Moqui requires 3 servers to run: database (embedded H2 for development),
115- OpenSearch (for search/indexing), and Moqui itself.
114+ Moqui requires 3 servers: database (embedded H2), OpenSearch, and Moqui itself.
116115
117- ** First-time setup** (one-time only ):
116+ ** Initial setup** (one-time):
118117``` bash
119- ./gradlew downloadOpenSearch # Downloads OpenSearch to runtime/opensearch
120- ./gradlew startElasticSearch # Start OpenSearch in daemon mode (stays running)
118+ ./gradlew downloadOpenSearch startElasticSearch load
121119```
122120
123- ** Standard development workflow :**
121+ ** Server lifecycle commands :**
124122``` bash
125- ./gradlew cleanAll # Stops OpenSearch, deletes all data (does NOT restart OpenSearch automatically)
126- ./gradlew startElasticSearch # Restart OpenSearch after cleanAll
127- ./gradlew load # Build framework and load seed/demo data
128- ```
129-
130- ** Starting the Moqui server:**
131-
132- Start the server in the background and wait for it to be ready:
133-
134- ``` bash
135- # IMPORTANT: Stop any existing server first to avoid port conflicts
136- pkill -f " gradlew run"
137- # Also kill any java process using port 8080 (in case Gradle spawned it)
138- kill $( ss -tlnp 2> /dev/null | grep :8080 | grep -oP ' pid=\K\d+' | head -1) 2> /dev/null || true
139- sleep 2
140-
141- # Start server in background (output goes to /tmp/moqui-server.log)
123+ # Start (always stop first to avoid port conflicts)
124+ pkill -f " gradlew run" ; kill -9 $( ss -tlnp 2> /dev/null | grep :8080 | grep -oP ' pid=\K\d+' ) 2> /dev/null; sleep 2
142125nohup ./gradlew run > /tmp/moqui-server.log 2>&1 &
126+ # Wait: grep -q "Started.*8080" /tmp/moqui-server.log (or use strings if binary)
143127
144- # Wait for server to be ready (typically within less than a minute)
145- for i in {1..60}; do
146- if grep -q " Started oejs.ServerConnector.*8080" /tmp/moqui-server.log 2> /dev/null || \
147- strings /tmp/moqui-server.log 2> /dev/null | grep -q " Started oejs.ServerConnector.*8080" ; then
148- echo " Server is ready!"
149- break
150- fi
151- sleep 1
152- done
153- ```
128+ # Stop
129+ pkill -f " gradlew run" ; kill -9 $( ss -tlnp 2> /dev/null | grep :8080 | grep -oP ' pid=\K\d+' ) 2> /dev/null; sleep 2
154130
155- ** Verifying Server is Running** :
156- ``` bash
157- # Test with a simple REST call
158- curl -u john.doe:moqui http://localhost:8080/rest/s1/mantle/parties
159- # Or check the log for the startup message (use strings if log is binary)
160- grep " Started oejs.ServerConnector.*8080" /tmp/moqui-server.log || strings /tmp/moqui-server.log | grep " Started oejs.ServerConnector.*8080"
131+ # Restart (required for: entity changes, configuration changes, SECA/EECA changes)
132+ # No restart needed for: service changes, screen changes, data file changes
161133```
162134
163- ** Stopping the Server ** :
135+ ** Verify running: **
164136``` bash
165- # IMPORTANT: Stop any existing server first to avoid port conflicts
166- pkill -f " gradlew run"
167- # Also kill any java process using port 8080 (in case Gradle spawned it)
168- kill $( ss -tlnp 2> /dev/null | grep :8080 | grep -oP ' pid=\K\d+' | head -1) 2> /dev/null || true
169- sleep 2
170- # Verify port is free
171- ss -tlnp 2> /dev/null | grep :8080 || echo " Port 8080 is free"
137+ curl -u john.doe:moqui http://localhost:8080/rest/s1/mantle/parties
172138```
173139
174- ** Notes:**
175- - ** ALWAYS stop any existing server before starting** to avoid port 8080 conflicts
176- - ` ./gradlew run ` does NOT auto-start OpenSearch - start it manually first with
177- ` ./gradlew startElasticSearch `
178- - Server logs available in ` /tmp/moqui-server.log ` AND in ` runtime/log/moqui.log `
179- - If the server doesn't respond after seeing the log message, wait 5-10 more
180- seconds for full initialization
181-
182- The server starts at http://localhost:8080 with default credentials: ` john.doe `
183- / ` moqui ` (super admin user created by demo data)
184-
185- ** Authentication** : Most curl examples require basic authentication with `-u
186- john.doe: moqui ` unless otherwise noted. This user is only available after
187- loading demo data (` ./gradlew load ` includes demo data by default).
140+ Server at http://localhost:8080 , credentials: ` john.doe ` / ` moqui ` (from demo data).
188141
189142### Data Management and Loading
190143
@@ -437,31 +390,6 @@ When developing screens (XML widget system → FreeMarker macros → HTML):
437390
4383916 . ** Fix issues and refresh** browser until UI works correctly
439392
440- ### When to Restart the Server
441- - ** No restart needed** : Service XML/Groovy changes, Screen XML changes, data
442- file changes
443- - ** Restart required** : Entity definition changes, SECA/EECA rule changes,
444- configuration changes (MoquiConf.xml), dependency changes
445- ** How to Restart the Server** :
446- ``` bash
447- # Stop the running server
448- pkill -f " gradlew run"
449- # Also kill any java process using port 8080 (in case Gradle spawned it)
450- kill $( ss -tlnp 2> /dev/null | grep :8080 | grep -oP ' pid=\K\d+' | head -1) 2> /dev/null || true
451- sleep 2
452- # Start it again in background
453- nohup ./gradlew run > /tmp/moqui-server.log 2>&1 &
454- # Wait for server to be ready (typically 2-5 seconds after previous startup)
455- for i in {1..60}; do
456- if grep -q " Started oejs.ServerConnector.*8080" /tmp/moqui-server.log 2> /dev/null || \
457- strings /tmp/moqui-server.log 2> /dev/null | grep -q " Started oejs.ServerConnector.*8080" ; then
458- echo " Server is ready!"
459- break
460- fi
461- sleep 1
462- done
463- ```
464-
465393### Key Testing Endpoints
466394
467395** UI Tools** (Recommended for development):
@@ -534,106 +462,29 @@ review past output.
534462
535463# # Troubleshooting
536464
537- # ## System State Verification
538-
539- Run these commands at any time to check system state:
540-
541- ` ` ` bash
542- # Check OpenSearch is running
543- ps aux | grep opensearch | grep -v grep
544- # Should show Java process with opensearch.bootstrap.OpenSearch
545-
546- # Check Moqui server is running and ready
547- grep " Started oejs.ServerConnector.*8080" runtime/log/moqui.log | tail -1
548- # Should show: Started oejs.ServerConnector@...{0.0.0.0:8080}
549-
550- # Check if data is loaded
551- ls -lh runtime/db/h2/moqui.mv.db
552- # Should be > 50MB if demo data loaded
553-
554- # Test authentication
555- curl -u john.doe:moqui http://localhost:8080/rest/s1/mantle/parties
556- # Should return JSON with partyIdList
557- ` ` `
558-
559465# ## Common Issues
560466
561- ** Server Won ' t Start** :
467+ ** Port 8080 conflict ** ( ` Failed to bind ` , ` Address already in use ` ) :
562468` ` ` bash
563- # 1. Check if OpenSearch is running
564- ps aux | grep opensearch | grep -v grep
565-
566- # 2. If not running, start it
567- ./gradlew startElasticSearch
568-
569- # 3. Check if port 8080 is already in use
570- lsof -i :8080
571- # If occupied, kill the process or use different port
572-
573- # 4. Check server logs for errors
574- tail -50 runtime/log/moqui.log
469+ pkill -f " gradlew run" ; kill -9 $( ss -tlnp 2> /dev/null | grep :8080 | grep -oP ' pid=\K\d+' ) 2> /dev/null; sleep 2
575470` ` `
576471
577- **Service Call Fails** (Decision Tree):
578- - **404 Error** → Service not exposed in `*.rest.xml`, use ServiceRun UI instead
579- - **403 Error** → Check service `authenticate` attribute and user permissions
580- - **500 Error** → Check server logs for stack trace and error details
581- - **Connection Refused** → Server not running, check with `grep ServerConnector
582- runtime/log/moqui.log`
583-
584- **Service Changes Not Applying**:
472+ ** OpenSearch not running** :
585473` ` ` bash
586- # 1. Wait 5 seconds for service cache to refresh
587- sleep 5
588-
589- # 2. Check for syntax errors in server logs
590- tail -20 runtime/log/moqui.log | grep -i error
591-
592- # 3. Verify file was saved correctly
593- grep "your-change-marker" path/to/YourService.xml
474+ ps aux | grep opensearch | grep -v grep # Verify
475+ ./gradlew startElasticSearch # Start if needed
594476` ` `
595477
596- **Data Load Fails**:
597- ```bash
598- # 1. Check for errors in gradle output
599- ./gradlew load 2>&1 | grep -i "error\|exception\|constraint"
600-
601- # 2. Common causes:
602- # - Foreign key violations (load seed before demo)
603- # - Duplicate primary keys
604- # - Invalid entity names (must be fully qualified)
478+ ** Service changes not applying** : Wait 5 seconds for cache refresh
605479
606- # 3. Load seed first, then demo
607- ./gradlew load -Ptypes=seed
608- ./gradlew load -Ptypes=demo
609- ```
480+ ** Entity changes not visible** : Restart server (see Server Management section)
610481
611- **Entity Changes Not Visible**:
612- ```bash
613- # Entity changes REQUIRE server restart
614- # 1. Stop server
615- pkill -f "gradlew run"
616-
617- # 2. Start server again in background
618- nohup ./gradlew run > /tmp/moqui-server.log 2>&1 &
619-
620- # 3. Wait for: Started oejs.ServerConnector.*8080
621- for i in {1..60}; do
622- if grep -q "Started oejs.ServerConnector.*8080" /tmp/moqui-server.log 2>/dev/null; then
623- echo "Server is ready!"
624- break
625- fi
626- sleep 1
627- done
628-
629- # 4. Test with EntityDataFind UI
630- ```
482+ ** Service call errors** :
483+ - 404 → Use ServiceRun UI (` /qapps/tools/Service/ServiceRun` )
484+ - 403 → Check permissions
485+ - 500 → Check ` tail runtime/log/moqui.log`
631486
632- **Can' t Access Entity via REST** :
633- - ** Entity REST** (` /rest/e1/` ) requires special permissions john.doe doesn' t
634- have
635- - **Use instead**: EntityDataFind UI or Custom REST API (if exposed in
636- `*.rest.xml`)
487+ ** Data load fails** : Server must be stopped first.
637488
638489# # Coding standards and criteria
639490
0 commit comments