0
# Command Line Interface
1
2
Complete standalone RQ Dashboard application with extensive configuration options. The CLI provides a full-featured web server for monitoring RQ systems with support for authentication, multiple Redis instances, and flexible deployment scenarios.
3
4
## Capabilities
5
6
### Main Entry Point
7
8
Primary entry point for the rq-dashboard console command, with automatic environment variable configuration.
9
10
```python { .api }
11
def main():
12
"""
13
Entry point for rq-dashboard console script.
14
15
Automatically configures from environment variables with RQ_DASHBOARD_ prefix.
16
All CLI options can be set via environment variables.
17
"""
18
```
19
20
Usage:
21
```python
22
from rq_dashboard.cli import main
23
24
if __name__ == "__main__":
25
main()
26
```
27
28
### Server Runner
29
30
Core server function with comprehensive configuration options for all deployment scenarios.
31
32
```python { .api }
33
def run(
34
bind="0.0.0.0",
35
port=9181,
36
url_prefix="",
37
username=None,
38
password=None,
39
config=None,
40
redis_url=[],
41
poll_interval=None,
42
extra_path=["."],
43
disable_delete=False,
44
debug=False,
45
verbose=False,
46
json=False,
47
**deprecated_kwargs
48
):
49
"""
50
Run the RQ Dashboard Flask server.
51
52
All configuration can be set on the command line or through environment
53
variables of the form RQ_DASHBOARD_*. For example RQ_DASHBOARD_USERNAME.
54
55
Args:
56
bind: IP or hostname to bind HTTP server (default: "0.0.0.0")
57
port: Port to bind HTTP server (default: 9181)
58
url_prefix: URL prefix for reverse proxy usage (default: "")
59
username: HTTP Basic Auth username (optional)
60
password: HTTP Basic Auth password (optional)
61
config: Configuration file (Python module on search path)
62
redis_url: Redis URL(s), can specify multiple (default: ["redis://127.0.0.1:6379"])
63
poll_interval: Refresh interval in milliseconds (optional)
64
extra_path: Directories to append to sys.path (default: ["."])
65
disable_delete: Disable delete jobs and cleanup registries (default: False)
66
debug: Enable Flask debug mode (default: False)
67
verbose: Enable verbose logging (default: False)
68
json: Enable JSONSerializer for RQ operations (default: False)
69
"""
70
```
71
72
### Flask App Factory
73
74
Creates a configured Flask application with RQ Dashboard blueprint.
75
76
```python { .api }
77
def make_flask_app(config, username, password, url_prefix, compatibility_mode=True):
78
"""
79
Return Flask app with default configuration and registered blueprint.
80
81
Args:
82
config: Python module name for configuration (optional)
83
username: HTTP Basic Auth username (optional)
84
password: HTTP Basic Auth password (optional)
85
url_prefix: URL prefix for blueprint registration (default: "")
86
compatibility_mode: Enable legacy configuration support (default: True)
87
88
Returns:
89
Flask: Configured Flask application with RQ Dashboard blueprint registered
90
"""
91
```
92
93
Usage example:
94
```python
95
from rq_dashboard.cli import make_flask_app
96
97
# Create app with basic auth
98
app = make_flask_app(
99
config="myapp.rq_config",
100
username="admin",
101
password="secret",
102
url_prefix="/rq"
103
)
104
105
# Run with custom configuration
106
app.run(host="0.0.0.0", port=8080, debug=True)
107
```
108
109
### Authentication Setup
110
111
Adds HTTP Basic Authentication to Flask blueprints.
112
113
```python { .api }
114
def add_basic_auth(blueprint, username, password, realm="RQ Dashboard"):
115
"""
116
Add HTTP Basic Auth to a blueprint.
117
118
Note: This is only for casual use! For production systems, use proper
119
authentication mechanisms provided by your Flask application framework.
120
121
Args:
122
blueprint: Flask Blueprint to protect
123
username: Required username for authentication
124
password: Required password for authentication
125
realm: Authentication realm name (default: "RQ Dashboard")
126
"""
127
```
128
129
## Command Line Options
130
131
### Connection Options
132
133
```bash
134
# Single Redis instance (default)
135
rq-dashboard --redis-url redis://localhost:6379
136
137
# Multiple Redis instances
138
rq-dashboard --redis-url redis://server1:6379 --redis-url redis://server2:6379
139
140
# Redis with authentication
141
rq-dashboard --redis-url redis://:password@localhost:6379
142
143
# Redis Sentinel
144
rq-dashboard --redis-url redis+sentinel://sentinel1:26379,sentinel2:26379/mymaster
145
```
146
147
### Server Options
148
149
```bash
150
# Custom host and port
151
rq-dashboard --bind 0.0.0.0 --port 9181
152
153
# URL prefix for reverse proxy
154
rq-dashboard --url-prefix /monitoring/rq
155
156
# Debug mode
157
rq-dashboard --debug
158
159
# Enable verbose logging
160
rq-dashboard --verbose
161
```
162
163
### Authentication Options
164
165
```bash
166
# HTTP Basic Auth
167
rq-dashboard --username admin --password secret
168
169
# Configuration file
170
rq-dashboard --config myapp.dashboard_config
171
```
172
173
### Advanced Options
174
175
```bash
176
# Custom polling interval (milliseconds)
177
rq-dashboard --poll-interval 5000
178
179
# Disable delete operations
180
rq-dashboard --disable-delete
181
182
# Add paths to Python path
183
rq-dashboard --extra-path /path/to/modules --extra-path /another/path
184
185
# Use JSON serializer for RQ operations
186
rq-dashboard --json
187
```
188
189
## Configuration File
190
191
Python module configuration example:
192
193
```python
194
# config.py
195
DEBUG = False
196
RQ_DASHBOARD_REDIS_URL = ['redis://localhost:6379', 'redis://localhost:6380']
197
RQ_DASHBOARD_POLL_INTERVAL = 5000
198
RQ_DASHBOARD_DISABLE_DELETE = True
199
```
200
201
Usage:
202
```bash
203
rq-dashboard --config config
204
```
205
206
## Environment Variables
207
208
All options can be configured via environment variables:
209
210
```bash
211
export RQ_DASHBOARD_REDIS_URL="redis://localhost:6379"
212
export RQ_DASHBOARD_USERNAME="admin"
213
export RQ_DASHBOARD_PASSWORD="secret"
214
export RQ_DASHBOARD_POLL_INTERVAL="5000"
215
export RQ_DASHBOARD_DISABLE_DELETE="true"
216
217
rq-dashboard
218
```
219
220
## Deployment Examples
221
222
### Docker Deployment
223
224
```dockerfile
225
FROM python:3.9
226
RUN pip install rq-dashboard
227
EXPOSE 9181
228
CMD ["rq-dashboard", "--bind", "0.0.0.0"]
229
```
230
231
### Systemd Service
232
233
```ini
234
[Unit]
235
Description=RQ Dashboard
236
After=redis.service
237
238
[Service]
239
Type=simple
240
User=rq-dashboard
241
WorkingDirectory=/opt/rq-dashboard
242
Environment=RQ_DASHBOARD_REDIS_URL=redis://localhost:6379
243
ExecStart=/usr/local/bin/rq-dashboard --bind 127.0.0.1 --port 9181
244
Restart=always
245
246
[Install]
247
WantedBy=multi-user.target
248
```
249
250
### Reverse Proxy Configuration
251
252
Nginx configuration for reverse proxy:
253
254
```nginx
255
location /rq/ {
256
proxy_pass http://127.0.0.1:9181/;
257
proxy_set_header Host $host;
258
proxy_set_header X-Real-IP $remote_addr;
259
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
260
}
261
```
262
263
Run with URL prefix:
264
```bash
265
rq-dashboard --url-prefix /rq --bind 127.0.0.1
266
```