Command-line interface documentation for PayNext management scripts and tools.
- Overview
- Service Management CLI
- Testing CLI
- Database Management CLI
- Docker Management CLI
- Deployment CLI
PayNext provides several command-line scripts for managing services, running tests, and deploying the platform. All scripts are located in the scripts/ directory.
Main service management script for building, starting, and stopping backend services.
Location: scripts/paynext.sh
| Command | Arguments | Description | Example |
|---|---|---|---|
build |
[service] | Build all services or specific service | ./scripts/paynext.sh build |
start |
[service] | Start all services or specific service | ./scripts/paynext.sh start user-service |
stop |
[service] | Stop all services or specific service | ./scripts/paynext.sh stop |
list |
- | List all service PIDs and statuses | ./scripts/paynext.sh list |
eureka-server- Service discovery serverapi-gateway- API gateway and routinguser-service- User management servicepayment-service- Payment processing servicenotification-service- Notification service
| Service | Port | Description |
|---|---|---|
| eureka-server | 8001 | Service registry |
| api-gateway | 8002 | API gateway |
| user-service | 8003 | User service |
| payment-service | 8004 | Payment service |
| notification-service | 8005 | Notification service |
Build All Services
./scripts/paynext.sh buildOutput:
2025-01-01 10:00:00 [INFO] Building eureka-server
2025-01-01 10:00:05 [SUCCESS] eureka-server built successfully
2025-01-01 10:00:05 [INFO] Building api-gateway
...
Start Specific Service
./scripts/paynext.sh start payment-serviceOutput:
2025-01-01 10:05:00 [INFO] Starting payment-service on port 8004...
2025-01-01 10:05:05 [INFO] [payment-service] started with PID 12345
2025-01-01 10:05:10 [SUCCESS] [payment-service] started successfully
Check Service Status
./scripts/paynext.sh listOutput:
Service PID Status
------- --- ------
eureka-server 12340 Running
api-gateway 12341 Running
user-service 12342 Running
payment-service 12345 Running
notification-service 12346 Running
Stop All Services
./scripts/paynext.sh stopService logs are stored in backend/logs/:
# View service logs
tail -f backend/logs/payment-service.log
# View all logs
tail -f backend/logs/*.logProcess IDs stored in backend/pids/:
# Check specific service PID
cat backend/pids/payment-service.pidAdvanced service management with health checks and restart capabilities.
Location: scripts/manage-services.sh
| Command | Arguments | Description | Example |
|---|---|---|---|
start |
[service] | Start service with health check | ./scripts/manage-services.sh start all |
stop |
[service] | Gracefully stop service | ./scripts/manage-services.sh stop api-gateway |
restart |
[service] | Restart service | ./scripts/manage-services.sh restart payment-service |
status |
- | Show detailed service status | ./scripts/manage-services.sh status |
health |
- | Check health of all services | ./scripts/manage-services.sh health |
logs |
service | View service logs | ./scripts/manage-services.sh logs user-service |
Start All Services with Health Check
./scripts/manage-services.sh start allRestart Specific Service
./scripts/manage-services.sh restart api-gatewayCheck Service Health
./scripts/manage-services.sh healthOutput:
Checking service health...
✓ eureka-server: UP (http://localhost:8001/actuator/health)
✓ api-gateway: UP (http://localhost:8002/actuator/health)
✓ user-service: UP (http://localhost:8003/actuator/health)
✓ payment-service: UP (http://localhost:8004/actuator/health)
✓ notification-service: UP (http://localhost:8005/actuator/health)
Comprehensive test runner for all project components.
Location: scripts/run_all_tests.sh
# Run all tests
./scripts/run_all_tests.sh
# Run with custom project directory
./scripts/run_all_tests.sh -d /path/to/project- Backend services (Maven tests)
- Web frontend (Jest tests)
- Mobile frontend (Jest tests)
- Integration tests
- End-to-end tests
======================================================================
Starting All Component Test Run
======================================================================
2025-01-01 10:00:00 [INFO] Component: payment-service
2025-01-01 10:00:00 [INFO] Executing: mvn clean verify
2025-01-01 10:02:30 [SUCCESS] PASS: payment-service in 150s
======================================================================
Test Summary (Audit Report)
======================================================================
Component Status Duration (s)
--------- ------ ------------
payment-service PASS 150
user-service PASS 120
web-frontend PASS 45
mobile-frontend PASS 60
api-gateway PASS 90
notification-service PASS 75
All test suites passed successfully! System is compliant.
Test reports saved in:
test-logs/- Test execution logstest-reports/- Coverage and detailed reports
# View test logs
cat test-logs/payment-service.log
# View coverage reports
open test-reports/payment-service-coverage/index.htmlFlexible test runner with filtering options.
Location: scripts/run_tests.sh
| Flag | Description | Example |
|---|---|---|
-s |
Specific service to test | -s payment-service |
-t |
Test type (unit/integration/e2e) | -t integration |
-c |
Generate coverage report | -c |
-v |
Verbose output | -v |
Run Unit Tests for Service
./scripts/run_tests.sh -s user-service -t unitRun Integration Tests with Coverage
./scripts/run_tests.sh -t integration -cRun All Tests Verbosely
./scripts/run_tests.sh -vDatabase administration tool for backup, restore, and maintenance.
Location: scripts/db_manager.sh
| Command | Arguments | Description | Example |
|---|---|---|---|
create |
database_name | Create new database | ./scripts/db_manager.sh create test_db |
drop |
database_name | Drop database | ./scripts/db_manager.sh drop test_db |
backup |
database_name [file] | Backup database | ./scripts/db_manager.sh backup payment_db backup.sql |
restore |
database_name file | Restore from backup | ./scripts/db_manager.sh restore payment_db backup.sql |
list |
- | List all databases | ./scripts/db_manager.sh list |
migrate |
database_name | Run migrations | ./scripts/db_manager.sh migrate user_db |
Create Database
./scripts/db_manager.sh create payment_dbBackup Database
./scripts/db_manager.sh backup payment_db /backups/payment_db_2025-01-01.sqlRestore Database
./scripts/db_manager.sh restore payment_db /backups/payment_db_2025-01-01.sqlList Databases
./scripts/db_manager.sh listOutput:
Databases:
- user_db (size: 45 MB)
- payment_db (size: 128 MB)
- notification_db (size: 23 MB)
- fraud_detection_db (size: 89 MB)
Build Docker images and manage Docker Compose stack.
Location: scripts/docker-build-and-compose.sh
# Build and start all services
./scripts/docker-build-and-compose.sh
# Build specific services
./scripts/docker-build-and-compose.sh user-service payment-service
# Force rebuild
./scripts/docker-build-and-compose.sh --rebuild| Flag | Description |
|---|---|
--rebuild |
Force rebuild all images |
--no-cache |
Build without cache |
--pull |
Pull latest base images |
Build and Start Stack
./scripts/docker-build-and-compose.shForce Rebuild with No Cache
./scripts/docker-build-and-compose.sh --rebuild --no-cacheAutomated Docker image building and pushing to registry.
Location: scripts/docker-auto-build-push.sh
# Build and push all images
./scripts/docker-auto-build-push.sh
# Build and push specific service
./scripts/docker-auto-build-push.sh payment-service
# Specify registry
./scripts/docker-auto-build-push.sh --registry gcr.io/myproject| Variable | Description | Default |
|---|---|---|
DOCKER_REGISTRY |
Docker registry URL | docker.io |
IMAGE_TAG |
Image tag | latest |
DOCKER_USERNAME |
Registry username | - |
DOCKER_PASSWORD |
Registry password | - |
Build and Push to Docker Hub
export DOCKER_REGISTRY=docker.io
export DOCKER_USERNAME=myusername
export DOCKER_PASSWORD=mypassword
./scripts/docker-auto-build-push.shBuild and Push with Custom Tag
export IMAGE_TAG=v1.0.0
./scripts/docker-auto-build-push.shAutomated Kubernetes deployment script.
Location: scripts/kubernetes-auto-deploy.sh
# Deploy to Kubernetes
./scripts/kubernetes-auto-deploy.sh
# Deploy to specific namespace
./scripts/kubernetes-auto-deploy.sh --namespace production
# Deploy with custom values
./scripts/kubernetes-auto-deploy.sh --values prod-values.yaml| Flag | Description | Example |
|---|---|---|
--namespace |
Kubernetes namespace | --namespace production |
--values |
Custom values file | --values prod-values.yaml |
--dry-run |
Simulate deployment | --dry-run |
--rollback |
Rollback to previous version | --rollback |
Deploy to Production
./scripts/kubernetes-auto-deploy.sh \
--namespace production \
--values infrastructure/kubernetes/prod-values.yamlDry Run Deployment
./scripts/kubernetes-auto-deploy.sh --dry-runRollback Deployment
./scripts/kubernetes-auto-deploy.sh --rollback --namespace productiondev_environment_setup.sh
Automated development environment setup.
Location: scripts/dev_environment_setup.sh
# Run setup
./scripts/dev_environment_setup.shThis script:
- Checks system prerequisites (Java, Maven, Node.js, Docker)
- Installs missing dependencies
- Configures environment variables
- Initializes databases
- Builds all services
- Starts development environment
./scripts/dev_environment_setup.shOutput:
Checking prerequisites...
✓ Java 17 found
✓ Maven 3.8.6 found
✓ Node.js 18.12.0 found
✓ Docker 20.10.21 found
Setting up environment...
✓ Created .env file
✓ Started MySQL container
✓ Started Redis container
✓ Started RabbitMQ container
Building services...
✓ Built eureka-server
✓ Built api-gateway
✓ Built user-service
✓ Built payment-service
Development environment ready!
Access points:
- Web Dashboard: http://localhost:3000
- API Gateway: http://localhost:8002
- Eureka: http://localhost:8001
# Build, start, and check status
./scripts/paynext.sh build && \
./scripts/paynext.sh start && \
./scripts/paynext.sh list# Build and test
./scripts/paynext.sh build && \
./scripts/run_all_tests.sh# Backup databases before deploy
./scripts/db_manager.sh backup user_db && \
./scripts/db_manager.sh backup payment_db && \
./scripts/kubernetes-auto-deploy.sh# Set log level
export LOG_LEVEL=DEBUG
# Run command with verbose output
./scripts/paynext.sh start 2>&1 | tee service-start.log# Follow service logs
tail -f backend/logs/payment-service.log
# Follow all logs
tail -f backend/logs/*.log
# Docker logs
docker-compose logs -f payment-service| Variable | Description | Default |
|---|---|---|
PAYNEXT_HOME |
Project root directory | Current directory |
LOG_LEVEL |
Logging level | INFO |
SPRING_PROFILES_ACTIVE |
Spring profile | dev |
DOCKER_REGISTRY |
Docker registry | docker.io |
# Temporary (current session)
export SPRING_PROFILES_ACTIVE=prod
# Permanent (add to ~/.bashrc or ~/.zshrc)
echo 'export SPRING_PROFILES_ACTIVE=prod' >> ~/.bashrc
source ~/.bashrc# Make scripts executable
chmod +x scripts/*.sh# Add scripts to PATH
export PATH="$PATH:$(pwd)/scripts"# Check logs
cat backend/logs/service-name.log
# Check if port is in use
lsof -i :8004
# Kill process on port
kill $(lsof -t -i:8004)- Usage Guide - Common usage workflows
- Configuration - Environment configuration
- Troubleshooting - Problem resolution