Setting Up ResilientDB GraphQL
This guide will help you set up ResilientDB GraphQL on your system. Follow these steps to get started.
Prerequisites
- Python 3.10 or higher
- pip (Python package manager)
- Virtual environment (recommended)
- Nginx (for production deployment)
Installation
- Clone the repository:
git clone https://github.com/apache/incubator-resilientdb-graphql.git
cd incubator-resilientdb-graphql
- Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Start the development server:
python3 app.py
The server will be available at http://localhost:5000/graphql
Production Deployment
For production deployment, follow these steps:
- Install Nginx:
sudo apt-get install nginx -y
- Configure Nginx as a reverse proxy:
sudo vim /etc/nginx/conf.d/flask.conf
Add the following configuration:
server {
listen 80;
server_name your_domain_or_ip;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
- Create a systemd service:
sudo vim /etc/systemd/system/flask.service
Add the following configuration:
[Unit]
Description=Gunicorn instance to serve Flask
After=network.target
[Service]
User=root
Group=www-data
WorkingDirectory=/path/to/your/app
Environment="PATH=/path/to/your/app/venv/bin"
ExecStart=/path/to/your/app/venv/bin/gunicorn --bind 0.0.0.0:8000 wsgi:app
[Install]
WantedBy=multi-user.target
- Start and enable the service:
sudo systemctl daemon-reload
sudo systemctl start flask
sudo systemctl enable flask
Troubleshooting
If you encounter any issues during installation, make sure you have all the prerequisites installed and your Python version is compatible.
Common issues and solutions:
-
Port already in use
- Check if another service is using port 5000
- Change the port in your configuration
-
Permission denied
- Ensure you have the correct permissions for the installation directory
- Use
sudo
for system-wide installations
-
Dependency conflicts
- Use a virtual environment to isolate dependencies
- Check for conflicting package versions
Next Steps
Once you have completed the setup, you can start using ResilientDB GraphQL. Check out the Usage Guide for examples and best practices.
Last updated on