https://github.com/qubistlabs/jcash-backend
https://github.com/qubistlabs/jcash-backend
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/qubistlabs/jcash-backend
- Owner: qubistlabs
- Created: 2018-04-16T13:32:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-06-18T18:08:25.000Z (5 months ago)
- Last Synced: 2025-08-04T15:33:50.864Z (3 months ago)
- Language: Python
- Size: 648 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# jcash
jcash(Jibrel jCash backend)
"Authorization: Token {token}". To get token use: `POST /auth/login/`
# Quick Start
## With docker-compose
First of all - get [Docker-Compose](https://docs.docker.com/compose/install/). Then:
- just start all components with one command:
```
docker-compose pull && docker-compose up
```
- build on your computer and start:
```
docker-compose up --build
```
## Post-install
Login to admin panel with default credentials:
- login: `admin`
- email: `admin@example.com`
- password: `Koochoo7eishiD8iex5theexeisahHah`
After login - create new user for yourself and disable default `admin` user for security reasons.
Don't delete it - or this account will be recreated with default password.
# Installation
## Install system packages
```sh
sudo apt-get update
sudo apt-get install gcc build-essential autoconf libtool pkg-config libssl-dev libffi-dev python3-dev virtualenv
sudo apt-get install git nginx
sudo apt-get install postgresql postgresql-contrib
```
## Install RabbitMQ (Celery`s dependency)
https://linoxide.com/ubuntu-how-to/install-setup-rabbitmq-ubuntu-16-04/
```sh
sudo apt-get update
sudo apt-get install rabbitmq-server
sudo systemctl enable rabbitmq-server
sudo systemctl start rabbitmq-server
sudo systemctl status rabbitmq-server
sudo rabbitmqctl add_user rabbituser rabbitpassword
sudo rabbitmqctl add_vhost rabbitvhost
sudo rabbitmqctl set_permissions -p rabbitvhost rabbituser ".*" ".*" ".*"
```
## Set up database
```
sudo -u postgres psql
postgres=# CREATE DATABASE mysaleuser;
postgres=# CREATE USER mysaleuser WITH PASSWORD 'password';
postgres=# ALTER ROLE mysaleuser SET client_encoding TO 'utf8';
postgres=# ALTER ROLE mysaleuser SET default_transaction_isolation TO 'read committed';
postgres=# ALTER ROLE mysaleuser SET timezone TO 'UTC';
postgres=# GRANT ALL PRIVILEGES ON DATABASE mysaledb TO mysaleuser;
postgres=# \q
```
## Clone project and create workdir
```
cd /home/jibrelnetwork
git clone https://github.com/jibrelnetwork/jibrel-jcash-backend
cd jibrel-jcash-backend
```
## Create python virtual environment
```sh
virtualenv -p /usr/bin/python3.6 venv
source venv/bin/activate
```
## Install packages
```sh
pip install -r requirements.txt
pip install --editable ./
```
## Configure
Check settings `./jcash/settings.py`
You can create dotenv file `./jcash/.env` and put all env vars here
## Init database
```sh
python jcash/manage.py migrate
```
## Launching Django server in dev mode
```sh
python jcash/manage.py runserver
```
## Deploying (Gunicorn)
### Testing Gunicorn's Ability to Serve the Project
```sh
cd ~/jcash
source venv/bin/activate
gunicorn --bind 0.0.0.0:8000 -w 4 jcash.wsgi
```
### Create a Gunicorn systemd Service File
```sh
sudo nano /etc/systemd/system/jcash.service
```
```
[Unit]
Description=jcash daemon
After=network.target
[Service]
User=jibrelnetwork
Group=www-data
WorkingDirectory=/home/jibrelnetwork/jibrel-jcash-backend/
ExecStart=/home/jibrelnetwork/jibrel-jcash-backend/venv/bin/gunicorn --access-logfile - --workers 4 --bind unix:/home/jibrelnetwork/jibrel-jcash-backend/jcash.sock jcash.wsgi:application
[Install]
WantedBy=multi-user.target
```
Commands
```
sudo systemctl start jcash
sudo systemctl restart jcash
sudo systemctl stop jcash
```
### Check response of web server
```
curl -H "Content-Type: application/json" -X POST -d '{"email":"test1@local","password":"password"}' http://localhost:8080/auth/login/
```
# Launch celery tasks
```
mkdir -p ./celery-sys/
mkdir -p ./celery-log/
source venv/bin/activate
celery -A jcash worker \
--pidfile="./celery-sys/%n.pid" \
--logfile="./celery-log/%n-%i.log" \
--loglevel=INFO
```
# Collects the static files into STATIC_ROOT.
```sh
python jcash/manage.py collectstatic
```