CLI Commands
Complete reference for zxwdb command-line interface.
Installation
bash
npm install -g @fiqihbadrian/zxwdbBasic Usage
Start Server
bash
zxwdbStarts the web server on port 20256.
Output:
🚀 zxwdb v1.0.12 - Visual Database Designer
Server running at:
➜ Local: http://localhost:20256
➜ Network: http://192.168.1.100:20256
Press Ctrl+C to stopVersion
bash
zxwdb --version
# or
zxwdb -vShows current version.
Help
bash
zxwdb --help
# or
zxwdb -hShows available commands and options.
Options (Future Features)
Custom Port
bash
# Coming soon
zxwdb --port 8080
zxwdb -p 8080Start on custom port.
Custom Host
bash
# Coming soon
zxwdb --host 0.0.0.0Bind to specific network interface.
Database Connection
bash
# Coming soon
zxwdb --db-host localhost --db-port 3306 --db-user rootPre-configure database connection.
Verbose Mode
bash
# Coming soon
zxwdb --verbose
zxwdb -VEnable detailed logging.
Quiet Mode
bash
# Coming soon
zxwdb --quiet
zxwdb -qSuppress non-error output.
Configuration File
bash
# Coming soon
zxwdb --config ./zxwdb.config.js
zxwdb -c ./zxwdb.config.jsLoad configuration from file.
Environment Variables
Server Configuration
bash
export ZXWDB_PORT=20256
export ZXWDB_HOST=localhostDatabase Configuration
bash
export ZXWDB_DB_HOST=localhost
export ZXWDB_DB_PORT=3306
export ZXWDB_DB_USER=root
export ZXWDB_DB_PASS=secret
export ZXWDB_DB_NAME=my_databaseFeature Flags
bash
export ZXWDB_AUTO_SAVE=true
export ZXWDB_THEME=dark
export ZXWDB_DEBUG=falseExamples
Basic Start
bash
zxwdbStart with Environment Variables
bash
ZXWDB_PORT=8080 zxwdbStart with All Options (Future)
bash
zxwdb \
--port 8080 \
--host 0.0.0.0 \
--db-host localhost \
--db-user root \
--verboseProcess Management
Run in Background
bash
# Using nohup
nohup zxwdb > zxwdb.log 2>&1 &
# Using screen
screen -S zxwdb
zxwdb
# Ctrl+A, D to detachStop Server
bash
# Find process
ps aux | grep zxwdb
# Kill process
kill <PID>
# Or use Ctrl+C in terminalAuto-Restart on Crash
bash
# Using forever
npm install -g forever
forever start $(which zxwdb)
# Using pm2
npm install -g pm2
pm2 start zxwdb --name "zxwdb-server"Systemd Service (Linux)
Create /etc/systemd/system/zxwdb.service:
ini
[Unit]
Description=zxwdb Visual Database Designer
After=network.target mysql.service
[Service]
Type=simple
User=www-data
WorkingDirectory=/opt/zxwdb
ExecStart=/usr/bin/zxwdb
Restart=on-failure
RestartSec=10
Environment="ZXWDB_PORT=20256"
Environment="ZXWDB_DB_HOST=localhost"
[Install]
WantedBy=multi-user.targetEnable and start:
bash
sudo systemctl enable zxwdb
sudo systemctl start zxwdb
sudo systemctl status zxwdbDocker
Run with Docker
bash
docker run -d \
--name zxwdb \
-p 20256:20256 \
-e ZXWDB_DB_HOST=host.docker.internal \
-e ZXWDB_DB_PORT=3306 \
-e ZXWDB_DB_USER=root \
-e ZXWDB_DB_PASS=secret \
fiqihbadrian/zxwdb:latestDocker Compose
Create docker-compose.yml:
yaml
version: '3.8'
services:
zxwdb:
image: fiqihbadrian/zxwdb:latest
ports:
- "20256:20256"
environment:
- ZXWDB_DB_HOST=mysql
- ZXWDB_DB_PORT=3306
- ZXWDB_DB_USER=root
- ZXWDB_DB_PASS=secret
- ZXWDB_DB_NAME=myapp
depends_on:
- mysql
restart: unless-stopped
mysql:
image: mysql:8.0
environment:
- MYSQL_ROOT_PASSWORD=secret
- MYSQL_DATABASE=myapp
volumes:
- mysql_data:/var/lib/mysql
restart: unless-stopped
volumes:
mysql_data:Start with:
bash
docker-compose up -dNginx Reverse Proxy
Configure Nginx:
nginx
server {
listen 80;
server_name db.example.com;
location / {
proxy_pass http://localhost:20256;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}Troubleshooting
Port Already in Use
bash
# Find process using port
lsof -i :20256 # macOS/Linux
netstat -ano | findstr :20256 # Windows
# Kill process
kill -9 <PID> # macOS/Linux
taskkill /PID <PID> /F # WindowsPermission Denied
bash
# Run with sudo (not recommended)
sudo zxwdb
# Or fix npm permissions
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.profile
source ~/.profileModule Not Found
bash
# Reinstall
npm uninstall -g @fiqihbadrian/zxwdb
npm install -g @fiqihbadrian/zxwdb
# Clear npm cache
npm cache clean --forceCommand Not Found
bash
# Check npm global bin path
npm bin -g
# Add to PATH
export PATH=$PATH:$(npm bin -g)
# Add to shell profile
echo 'export PATH=$PATH:'$(npm bin -g) >> ~/.bashrc
source ~/.bashrcAdvanced Usage
Custom Node Options
bash
# Increase memory limit
NODE_OPTIONS="--max-old-space-size=4096" zxwdb
# Enable debugging
NODE_OPTIONS="--inspect" zxwdbDevelopment Mode
bash
# Clone repository
git clone https://github.com/fiqihbadrian/zxwdb.git
cd zxwdb
# Install dependencies
npm install
# Run in development
npm run devBuild from Source
bash
# Clone and build
git clone https://github.com/fiqihbadrian/zxwdb.git
cd zxwdb
# Install and build
npm install
npm run build
# Link globally
npm linkLogging
View Logs
bash
# Redirect to file
zxwdb > zxwdb.log 2>&1
# View in real-time
tail -f zxwdb.logLog Levels (Future)
bash
zxwdb --log-level debug
zxwdb --log-level info
zxwdb --log-level warn
zxwdb --log-level errorPerformance Tuning
Node.js Options
bash
# Increase V8 heap
NODE_OPTIONS="--max-old-space-size=8192" zxwdb
# Enable performance monitoring
NODE_OPTIONS="--perf-prof" zxwdbConnection Pooling
Set environment variables:
bash
export ZXWDB_DB_POOL_SIZE=20
export ZXWDB_DB_POOL_QUEUE=0Security
Firewall Rules
bash
# Allow only localhost
sudo ufw allow from 127.0.0.1 to any port 20256
# Allow specific IP
sudo ufw allow from 192.168.1.0/24 to any port 20256Authentication (Future)
bash
zxwdb --auth --username admin --password secretHTTPS (Future)
bash
zxwdb --https --cert ./cert.pem --key ./key.pemExit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error |
| 2 | Port in use |
| 3 | Database connection failed |
| 130 | Terminated by Ctrl+C |
Command Reference
Available Now
zxwdb- Start serverzxwdb --version- Show versionzxwdb --help- Show help
Coming Soon
zxwdb init- Initialize configurationzxwdb migrate- Run migrationszxwdb export- Export schemazxwdb import- Import schemazxwdb validate- Validate schema
Integration Examples
npm Scripts
json
{
"scripts": {
"db:designer": "zxwdb",
"db:start": "zxwdb --port 8080"
}
}VS Code Tasks
Create .vscode/tasks.json:
json
{
"version": "2.0.0",
"tasks": [
{
"label": "Start zxwdb",
"type": "shell",
"command": "zxwdb",
"isBackground": true,
"problemMatcher": []
}
]
}