API for internal resources
Needs: Python 3.X, virtualenv
git clone https://github.com/hackcu/api && cd api
virtualenv env --python=python3
source ./env/bin/activate
pip install -r requirements.txt
- Set up (see above)
python manage.py runserver
- Sit back, relax and enjoy. That's it!
Inspired on this tutorial to understand and set it up as in our server.
- Set up (see above)
- Create server.sh from template:
cp server.sh.template server.sh
chmod +x server.sh
- Edit variables to match your environment and add extra if required (see environment variables available above)
- Create restart.sh from template:
cp restart.sh.template restart.sh
chmod +x restart.sh
- Edit variables to match your environment and add extra if required (see environment variables available above)
- Run
restart.sh
. This will update the database, dependecies and static files. - Set up Systemd (read next section)
Needs: Systemd.
- Edit this file
/etc/systemd/system/api.service
- Add this content
[Unit]
Description=api daemon
After=network.target
[Service]
User=user
Group=www-data
WorkingDirectory=/home/user/project_folder
ExecStart=/home/user/project_folder/server.sh >>/home/user/project_folder/out.log 2>>/home/user/project_folder/error.log
[Install]
WantedBy=multi-user.target
- Replace
user
for your linux user. - Replace
project_folder
by the name of the folder where the project is located - Create and enable service:
sudo systemctl start api && sudo systemctl enable api
git pull
./restart.sh
sudo service api restart
- DEBUG(optional): Set to
false
to disable debug mode on production. - SECRET(optional): Sets web application secret. You can generate a random secret with python running:
os.urandom(24)
- DATABASE_URL(optional): URL to connect to the database. If not sets, defaults to django default SQLite database. See schema for different databases here.
- DOMAIN(optional): Domain where app will be running. Default: None
- SLACK(optional): Slack token to invite hackers automatically on confirmation. You can obtain it here
- SENDGRID(optional): SendGrid API Key. You can manage them here. Note that if you don't add it the system will write all emails in the filesystem for preview.
Read these guidelines carefully.
By making a contribution, in any form (including, but not limited to, Issues and Pull Requests), you agree to abide by the Code of Conduct. Report any incidents to report@gerard.space and appropriate action will be taken against the offender after investigation.
MIT Β© HackCU