Compare commits
11 Commits
nginx-unit
...
7375ffe830
Author | SHA1 | Date | |
---|---|---|---|
7375ffe830 | |||
8ba82ef0db | |||
f7093e5e58 | |||
19c5b0830a | |||
23c1ff7140 | |||
8187817752 | |||
9160a37378 | |||
fd77792688 | |||
9f5e2e93dd | |||
3a2a2ce268 | |||
48443d9855 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,10 +1,9 @@
|
|||||||
# project specific
|
# project specific
|
||||||
settings.json
|
#settings.json
|
||||||
db.sqlite3
|
db.sqlite3
|
||||||
dummyusers.json
|
dummyusers.json
|
||||||
*.prof
|
*.prof
|
||||||
statictest.txt
|
|
||||||
./test.sh
|
|
||||||
|
|
||||||
# IDE
|
# IDE
|
||||||
.vscode
|
.vscode
|
||||||
|
@@ -23,10 +23,9 @@ with open(BASE_DIR + "/settings.json", "r") as userfile:
|
|||||||
CALIBRE_DIR = os.path.abspath(usersettings["CALIBRE_DIR"])
|
CALIBRE_DIR = os.path.abspath(usersettings["CALIBRE_DIR"])
|
||||||
SECRET_KEY = usersettings["SECRET_KEY"]
|
SECRET_KEY = usersettings["SECRET_KEY"]
|
||||||
ALLOWED_HOSTS = usersettings["ALLOWED_HOSTS"]
|
ALLOWED_HOSTS = usersettings["ALLOWED_HOSTS"]
|
||||||
|
INTERNAL_IPS = usersettings["INTERNAL_IPS"]
|
||||||
DEBUG = usersettings["DEBUG"]
|
DEBUG = usersettings["DEBUG"]
|
||||||
|
|
||||||
DOCKER = os.environ.get('AM_DOCKER_INSTANCE', False)
|
|
||||||
|
|
||||||
|
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
|
|
||||||
@@ -65,41 +64,38 @@ STATIC_ROOT = BASE_DIR + "/static/"
|
|||||||
#########################################################################
|
#########################################################################
|
||||||
# LOGGING
|
# LOGGING
|
||||||
|
|
||||||
# TODO: think about the issue for a bit. no write access to file on first run
|
|
||||||
# but startscript doesn't run to give access if it can't start django
|
|
||||||
# if not DOCKER:
|
logfile = usersettings["LOGFOLDER"] + "django.log"
|
||||||
# logfile = "/app//data//django.log"
|
LOGGING = {
|
||||||
# if not os.path.isfile(logfile):
|
"version": 1,
|
||||||
# os.mknod(logfile)
|
"disable_existing_loggers": False,
|
||||||
# LOGGING = {
|
"root": {"level": "INFO", "handlers": ["file"]},
|
||||||
# "version": 1,
|
"handlers": {
|
||||||
# "disable_existing_loggers": False,
|
"file": {
|
||||||
# "root": {"level": "INFO", "handlers": ["file"]},
|
"level": "INFO",
|
||||||
# "handlers": {
|
"class": "logging.FileHandler",
|
||||||
# "file": {
|
"filename": logfile,
|
||||||
# "level": "INFO",
|
"formatter": "app",
|
||||||
# "class": "logging.FileHandler",
|
},
|
||||||
# "filename": logfile,
|
},
|
||||||
# "formatter": "app",
|
"loggers": {
|
||||||
# },
|
"django": {
|
||||||
# },
|
"handlers": ["file"],
|
||||||
# "loggers": {
|
"level": "INFO",
|
||||||
# "django": {
|
"propagate": True
|
||||||
# "handlers": ["file"],
|
},
|
||||||
# "level": "INFO",
|
},
|
||||||
# "propagate": True
|
"formatters": {
|
||||||
# },
|
"app": {
|
||||||
# },
|
"format": (
|
||||||
# "formatters": {
|
u"%(asctime)s [%(levelname)-8s] "
|
||||||
# "app": {
|
"(%(module)s.%(funcName)s) %(message)s"
|
||||||
# "format": (
|
),
|
||||||
# u"%(asctime)s [%(levelname)-8s] "
|
"datefmt": "%Y-%m-%d %H:%M:%S",
|
||||||
# "(%(module)s.%(funcName)s) %(message)s"
|
},
|
||||||
# ),
|
},
|
||||||
# "datefmt": "%Y-%m-%d %H:%M:%S",
|
}
|
||||||
# },
|
|
||||||
# },
|
|
||||||
# }
|
|
||||||
|
|
||||||
|
|
||||||
## ##
|
## ##
|
||||||
@@ -144,7 +140,6 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
"library",
|
"library",
|
||||||
"django_extensions"
|
|
||||||
# "silk", # DEBUG/profilling purposes
|
# "silk", # DEBUG/profilling purposes
|
||||||
# 'debug_toolbar', # DEBUG purposes
|
# 'debug_toolbar', # DEBUG purposes
|
||||||
]
|
]
|
||||||
@@ -194,23 +189,19 @@ WSGI_APPLICATION = 'CalibreWebCompanion.wsgi.application'
|
|||||||
## DATBASE ##
|
## DATBASE ##
|
||||||
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
||||||
|
|
||||||
|
if usersettings["ISDOCKER"]:
|
||||||
if DOCKER:
|
defaultdb_path = "calibre"
|
||||||
djangodb_path = "/app/CalibreWebCompanion"
|
|
||||||
calibredb_path = "/app/content/"
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
djangodb_path = BASE_DIR
|
defaultdb_path = BASE_DIR
|
||||||
calibredb_path = CALIBRE_DIR
|
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': os.path.join(djangodb_path, 'db.sqlite3'),
|
'NAME': os.path.join(defaultdb_path, 'db.sqlite3'),
|
||||||
},
|
},
|
||||||
'calibre': {
|
'calibre': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': os.path.join(calibredb_path, 'metadata.db'),
|
'NAME': os.path.join(CALIBRE_DIR, 'metadata.db'),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
CalibreWebCompanion/CalibreWebCompanion/uwsgi.ini
Normal file
20
CalibreWebCompanion/CalibreWebCompanion/uwsgi.ini
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
[uwsgi]
|
||||||
|
base = /cwebcomp
|
||||||
|
chdir = %(base)
|
||||||
|
home = %(base)
|
||||||
|
pidfile= %(base)/cwebcomp.pid
|
||||||
|
pythonpath= /usr/local
|
||||||
|
uid = www-data
|
||||||
|
gid = www-data
|
||||||
|
module = wsgi:application # path to wsgy.py file
|
||||||
|
socket = :8000
|
||||||
|
processes = 8
|
||||||
|
threads = 4
|
||||||
|
master = true
|
||||||
|
chmod-socket = 660
|
||||||
|
vacuum = true
|
||||||
|
die-on-term = true
|
||||||
|
harakiri = 20
|
||||||
|
max-requests = 5000
|
||||||
|
logs = %(base)/uwsgi_info.logs
|
||||||
|
daemonize = %(base)/uwsgi.logs
|
33
CalibreWebCompanion/gunicorn.conf.py
Normal file
33
CalibreWebCompanion/gunicorn.conf.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import multiprocessing
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
|
||||||
|
bind = "127.0.0.1:8000"
|
||||||
|
workers = multiprocessing.cpu_count() * 2 + 1
|
||||||
|
preload_app = True # By preloading an application you can save some RAM resources as well as speed up server boot times
|
||||||
|
keepalive = 5
|
||||||
|
# daemon = True # Detaches the server from the controlling terminal and enters the background. disabled for now
|
||||||
|
# logging
|
||||||
|
|
||||||
|
with open("settings.json", "r") as jfile:
|
||||||
|
settings = json.load(jfile)
|
||||||
|
|
||||||
|
errorlog = settings["LOGFOLDER"] + "/gunicorn_error.log"
|
||||||
|
loglevel = "warning"
|
||||||
|
accesslog = settings["LOGFOLDER"] + "/gunicorn_access.log"
|
||||||
|
|
||||||
|
if not os.path.isdir("/usr/src/app/data/logs"):
|
||||||
|
os.mkdir("/usr/src/app/data/logs")
|
||||||
|
if not os.path.isfile(errorlog):
|
||||||
|
os.system('touch {}'.format(errorlog))
|
||||||
|
if not os.path.isfile(accesslog):
|
||||||
|
os.system('touch {}'.format(accesslog))
|
||||||
|
capture_output = True
|
||||||
|
|
||||||
|
# debug settings which need to be commented out in prod
|
||||||
|
# reload=True
|
||||||
|
# reload_engine = "inotify"
|
||||||
|
|
||||||
|
|
||||||
|
# I only went till the section https://docs.gunicorn.org/en/latest/settings.html#logging there are more settings
|
||||||
|
# some of them might be useful
|
@@ -6,7 +6,7 @@
|
|||||||
<div class="col s12 m7">
|
<div class="col s12 m7">
|
||||||
<div class="card z-depth-0 horizontal">
|
<div class="card z-depth-0 horizontal">
|
||||||
<div class="card-image">
|
<div class="card-image">
|
||||||
<a style="padding-top:15%" href=" /content/{{download}}"><img src=" /content/{{imgpath}}"
|
<a style="padding-top:15%" href=" /download/{{download}}"><img src=" /download/{{imgpath}}"
|
||||||
alt="download" srcset=""></a>
|
alt="download" srcset=""></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-stacked">
|
<div class="card-stacked">
|
||||||
|
15
CalibreWebCompanion/settings.json
Normal file
15
CalibreWebCompanion/settings.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"CALIBRE_DIR": "calibre",
|
||||||
|
"SECRET_KEY": "u(8^+rb%rz5hsx4v^^y(ul7g(4n7a8!db@s*9(m5cs*2_ppy8+",
|
||||||
|
"ALLOWED_HOSTS": [
|
||||||
|
"127.0.0.1"
|
||||||
|
],
|
||||||
|
"INTERNAL_IPS": [
|
||||||
|
"127.0.0.1"
|
||||||
|
],
|
||||||
|
"DEBUG" : true,
|
||||||
|
"LOGFOLDER" : "/cwebcomp/logs",
|
||||||
|
"ISDOCKER" : true
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"CALIBRE_DIR": "/app/content",
|
|
||||||
"LOGFOLDER" : "/usr/src/app/data/logs/",
|
|
||||||
"SECRET_KEY": "u(8^+rb%rz5hsx4v^^y(ul7g(4n7a8!db@s*9(m5cs*2_ppy8+",
|
|
||||||
"ALLOWED_HOSTS": [
|
|
||||||
"*"
|
|
||||||
],
|
|
||||||
"INTERNAL_IPS": [
|
|
||||||
"127.0.0.1", "localhost"
|
|
||||||
],
|
|
||||||
"DEBUG" : false
|
|
||||||
|
|
||||||
}
|
|
35
Dockerfile
Normal file
35
Dockerfile
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
FROM python:3.9.1-slim-buster
|
||||||
|
|
||||||
|
RUN apt-get clean && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y nginx smbclient default-libmysqlclient-dev \
|
||||||
|
gcc python3-cffi libcairo2 libpango-1.0-0 libpangocairo-1.0-0 \
|
||||||
|
libgdk-pixbuf2.0-0 libffi-dev shared-mime-info
|
||||||
|
|
||||||
|
# set environment variables
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE 1
|
||||||
|
ENV PYTHONUNBUFFERED 1
|
||||||
|
|
||||||
|
RUN mkdir /cwebcomp
|
||||||
|
WORKDIR /cwebcomp
|
||||||
|
ADD . /cwebcomp/
|
||||||
|
# only add this next one if you have static files
|
||||||
|
RUN mkdir static
|
||||||
|
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
RUN python CalibreWebCompanion/manage.py collectstatic
|
||||||
|
|
||||||
|
# only if you need celery
|
||||||
|
#RUN useradd -ms /bin/bash celery
|
||||||
|
#COPY broker/init.d_celeryd /etc/init.d/celeryd
|
||||||
|
#COPY broker/celeryd /etc/default/celeryd
|
||||||
|
|
||||||
|
# nginx config and script to be run
|
||||||
|
COPY deployment/docker/nginx.conf /etc/nginx/sites-available/default
|
||||||
|
COPY deployment/docker/start.sh /usr/local/bin/start.sh
|
||||||
|
|
||||||
|
# set proper file permissions
|
||||||
|
RUN chmod u+x /usr/local/bin/start.sh
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
CMD ["/bin/bash", "-c", "start.sh"]
|
@@ -1,23 +1,29 @@
|
|||||||
|
|
||||||
## pull official base image
|
## pull official base image
|
||||||
FROM nginx/unit:1.22.0-python3.9
|
FROM python:slim-buster
|
||||||
EXPOSE 80
|
EXPOSE 8080
|
||||||
ENV AM_DOCKER_INSTANCE Yes
|
|
||||||
## set work directory
|
## set work directory
|
||||||
WORKDIR /app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
## install dependencies
|
## install dependencies
|
||||||
|
RUN pip install --upgrade pip
|
||||||
COPY ./requirements.txt .
|
COPY ./requirements.txt .
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
|
RUN apk add nginx supervisor
|
||||||
|
|
||||||
|
# do nginx stuff
|
||||||
|
RUN adduser -D -g 'www' www
|
||||||
|
RUN mkdir -p /run/nginx
|
||||||
|
COPY ./deployment/nginx.conf /etc/nginx/
|
||||||
|
|
||||||
## copy project
|
## copy project
|
||||||
COPY ./CalibreWebCompanion ./CalibreWebCompanion
|
COPY ./CalibreWebCompanion ./CalibreWebCompanion
|
||||||
|
COPY ./deployment/startupscript.py ./
|
||||||
|
## gunicorn borks started with supervisord
|
||||||
|
COPY ./deployment/supervisord.conf /etc/
|
||||||
|
ENTRYPOINT /usr/bin/supervisord -c /etc/supervisord.conf
|
||||||
|
|
||||||
# perms
|
|
||||||
RUN chown -R unit:unit /app
|
|
||||||
COPY ./deployment/entrypoints/* /docker-entrypoint.d/
|
|
||||||
RUN chmod +x /docker-entrypoint.d/start.sh
|
|
||||||
|
|
||||||
# docker run --publish 80:80 \
|
# docker run --publish 8000:80 \
|
||||||
# -v '/home/MassiveAtoms/Desktop/logs:/app/data' \
|
# -v '/home/massiveatoms/Desktop/logs:/usr/src/app/data' \
|
||||||
# -v '/home/MassiveAtoms/windows/Users/MassiveAtoms/Documents/Calibre Library/:/app/calibredir' \
|
# -v '/run/media/massiveatoms/1AEEEA6EEEEA421D1/Documents and Settings/MassiveAtoms/Documents/Calibre Library/:/usr/src/app/calibredir' \
|
||||||
# --name cw calibreweb:1.0
|
# --name cw calibreweb:1.0.1
|
||||||
|
4
deployment/deploy.py
Normal file
4
deployment/deploy.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
from os import environ
|
||||||
|
|
||||||
|
|
||||||
|
|
20
deployment/docker/nginx.conf
Normal file
20
deployment/docker/nginx.conf
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name 127.0.0.1;
|
||||||
|
charset utf-8;
|
||||||
|
client_max_body_size 75M;
|
||||||
|
|
||||||
|
|
||||||
|
location /static/ {
|
||||||
|
alias /cwebcomp/static/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /media/ {
|
||||||
|
alias /cwebcomp/media/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
include uwsgi_params;
|
||||||
|
uwsgi_pass 127.0.0.1:8000;
|
||||||
|
}
|
||||||
|
}
|
4
deployment/docker/start.sh
Normal file
4
deployment/docker/start.sh
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
uwsgi --ini app.ini --venv /usr/local
|
||||||
|
nginx -g 'daemon off;'
|
@@ -1,54 +0,0 @@
|
|||||||
{
|
|
||||||
"listeners": {
|
|
||||||
"*:80": {
|
|
||||||
"pass": "routes"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"routes": [
|
|
||||||
{
|
|
||||||
"match": {
|
|
||||||
"uri": [
|
|
||||||
"/content/*",
|
|
||||||
"!~\\.db"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"action": {
|
|
||||||
"share": "/app/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"match": {
|
|
||||||
"uri": "/static/*"
|
|
||||||
},
|
|
||||||
"action": {
|
|
||||||
"share": "/app/CalibreWebCompanion/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"match": {
|
|
||||||
"uri": [
|
|
||||||
"!~\\.db", "*"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"action": {
|
|
||||||
"pass": "applications/django"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"applications": {
|
|
||||||
"django": {
|
|
||||||
"type": "python 3",
|
|
||||||
"path": "/app/CalibreWebCompanion/",
|
|
||||||
"module": "CalibreWebCompanion.wsgi",
|
|
||||||
"environment": {
|
|
||||||
"DJANGO_SETTINGS_MODULE": "CalibreWebCompanion.settings",
|
|
||||||
"DB_ENGINE": "django.db.backends.sqlite3"
|
|
||||||
},
|
|
||||||
"processes" : {
|
|
||||||
"max": 25,
|
|
||||||
"spare": 1,
|
|
||||||
"idle_timeout": 20
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,22 +0,0 @@
|
|||||||
CAL_DIR="/app/content/"
|
|
||||||
DATA_DIR="/app/data/"
|
|
||||||
CWC_PATH="/app/CalibreWebCompanion"
|
|
||||||
if [ ! -d "$CAL_DIR" ]; then
|
|
||||||
echo "Calibre Library not mounted at the correct location."
|
|
||||||
echo "Mount it at /app/content/"
|
|
||||||
echo "Exiting..."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d "$DATA_DIR" ]; then
|
|
||||||
echo "A data directory not mounted at the correct location, exiting"
|
|
||||||
echo "This is used to store the database and logs"
|
|
||||||
echo "mount something at /app/data/"
|
|
||||||
echo "exiting"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cp -R -u -p "/app/CalibreWebCompanion/db.sqlite3" "/app/data/"
|
|
||||||
ls -l /app
|
|
||||||
python "${CWC_PATH}/manage.py" makemigrations
|
|
||||||
python "${CWC_PATH}/manage.py" migrate
|
|
@@ -8,12 +8,12 @@
|
|||||||
Here's an example of step 5
|
Here's an example of step 5
|
||||||
```
|
```
|
||||||
docker run --publish 80:80\
|
docker run --publish 80:80\
|
||||||
-v '/home/MassiveAtoms/Desktop/logs:/app/data' \
|
-v '/home/massiveatoms/Desktop/logs:/usr/src/app/data' \
|
||||||
-v '/home/MassiveAtoms/windows/Users/MassiveAtoms/Documents/Calibre\ Library/:/app/calibredir' \
|
-v '/run/media/massiveatoms/1AEEEA6EEEEA421D/Documents and Settings/MassiveAtoms/Documents/Calibre Library/:/usr/src/app/calibredir' \
|
||||||
--name cw calibreweb:1.0
|
--name cw calibreweb:1.0.1
|
||||||
```
|
```
|
||||||
|
|
||||||
your Calibre path/volume/whatever needs to be mounted at `/app/calibredir`, and you need to mount a volume for the db and logs at `/app/data`
|
your Calibre path/volume/whatever needs to be mounted at `/usr/src/app/calibredir`, and you need to mount a volume for the db and logs at `/usr/src/app/data`
|
||||||
|
|
||||||
Issues with it at the moment:
|
Issues with it at the moment:
|
||||||
1. we still need to do something to create a random secret key. Atm, this would still
|
1. we still need to do something to create a random secret key. Atm, this would still
|
||||||
|
81
deployment/nginx.conf
Normal file
81
deployment/nginx.conf
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
worker_processes 1;
|
||||||
|
|
||||||
|
# user nobody nogroup;
|
||||||
|
user www www; # TEMP disabled
|
||||||
|
# user nobody nobody; # for systems with 'nobody' as a group instead
|
||||||
|
error_log /usr/src/app/data/logs/nginx.log warn;
|
||||||
|
# pid /var/run/nginx.pid;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024; # increase if you have lots of clients
|
||||||
|
accept_mutex off; # set to 'on' if nginx worker_processes > 1
|
||||||
|
use epoll; # to enable for Linux 2.6+ MASSIVEATOMS
|
||||||
|
# 'use kqueue;' to enable for FreeBSD, OSX
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
include mime.types;
|
||||||
|
# fallback in case we can't determine a type
|
||||||
|
default_type application/octet-stream;
|
||||||
|
access_log /var/log/nginx/access.log combined;
|
||||||
|
sendfile on;
|
||||||
|
|
||||||
|
upstream app_server {
|
||||||
|
# fail_timeout=0 means we always retry an upstream even if it failed
|
||||||
|
# to return a good HTTP response
|
||||||
|
|
||||||
|
# for UNIX domain socket setups
|
||||||
|
# server unix:/tmp/gunicorn.sock fail_timeout=0;
|
||||||
|
|
||||||
|
# for a TCP configuration
|
||||||
|
server 127.0.0.1:8000 fail_timeout=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
# if no Host match, close the connection to prevent host spoofing
|
||||||
|
listen 80 default_server;
|
||||||
|
return 444;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80 deferred; # for Linux massiveatoms
|
||||||
|
# use 'listen 80 accept_filter=httpready;' for FreeBSD
|
||||||
|
# listen 80;
|
||||||
|
client_max_body_size 4G;
|
||||||
|
|
||||||
|
# set the correct host(s) for your site
|
||||||
|
server_name localhost 0.0.0.0; # set this to the server url? or ip? we'll see MASSIVEATOMS
|
||||||
|
|
||||||
|
keepalive_timeout 5;
|
||||||
|
|
||||||
|
# # MASSIVEATOMS
|
||||||
|
location /download/ {
|
||||||
|
alias "/usr/src/app/calibredir/";
|
||||||
|
# Never forget the fact that this little statement being root instead of alias caused us to lose more than a day troubleshooting
|
||||||
|
}
|
||||||
|
|
||||||
|
location /static/ {
|
||||||
|
alias "/usr/src/app/CalibreWebCompanion/static/";
|
||||||
|
# Never forget the fact that this little statement being root instead of alias caused us to lose more than a day troubleshooting
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
# proxy_set_header Host $http_host;
|
||||||
|
# we don't want nginx trying to do something clever with
|
||||||
|
# redirects, we set the Host: header above already.
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_pass http://127.0.0.1:8000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
error_page 500 502 503 504 /500.html;
|
||||||
|
location = /500.html {
|
||||||
|
root /path/to/app/current/public;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
deployment/startupscript.py
Normal file
11
deployment/startupscript.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from os import system, chdir
|
||||||
|
|
||||||
|
|
||||||
|
# system("chown -R www:www /usr/src/app/calibredir")
|
||||||
|
# print("ownership of calibredir changed")
|
||||||
|
chdir("/usr/src/app/CalibreWebCompanion")
|
||||||
|
system("python ./manage.py makemigrations")
|
||||||
|
print("ran makemigrations")
|
||||||
|
system("python ./manage.py migrate")
|
||||||
|
print("migrate")
|
||||||
|
|
36
deployment/supervisord.conf
Normal file
36
deployment/supervisord.conf
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
[supervisord]
|
||||||
|
nodaemon=true
|
||||||
|
logfile=/tmp/supervisord.log
|
||||||
|
childlogdir=/tmp
|
||||||
|
pidfile = /tmp/supervisord.pid
|
||||||
|
|
||||||
|
[program:gunicorn]
|
||||||
|
directory=/usr/src/app/CalibreWebCompanion
|
||||||
|
command=gunicorn CalibreWebCompanion.wsgi
|
||||||
|
stdout_logfile=/dev/stdout
|
||||||
|
stdout_logfile_maxbytes=0
|
||||||
|
stderr_logfile=/dev/stderr
|
||||||
|
stderr_logfile_maxbytes=0
|
||||||
|
autorestart=false
|
||||||
|
startretries=0
|
||||||
|
startsecs = 0
|
||||||
|
|
||||||
|
[program:nginx]
|
||||||
|
# user=www
|
||||||
|
command=nginx
|
||||||
|
stdout_logfile=/dev/stdout
|
||||||
|
stdout_logfile_maxbytes=0
|
||||||
|
stderr_logfile=/dev/stderr
|
||||||
|
stderr_logfile_maxbytes=0
|
||||||
|
autorestart=false
|
||||||
|
startretries=0
|
||||||
|
|
||||||
|
[program:startupscript]
|
||||||
|
directory=/usr/src/app
|
||||||
|
command=python ./startupscript.py
|
||||||
|
stdout_logfile=/dev/stdout
|
||||||
|
stdout_logfile_maxbytes=0
|
||||||
|
stderr_logfile=/dev/stderr
|
||||||
|
stderr_logfile_maxbytes=0
|
||||||
|
autorestart=false
|
||||||
|
startretries=0
|
@@ -1,7 +1,6 @@
|
|||||||
django>=3.0.8
|
django>=3.0.8
|
||||||
inotify>=0.2.10
|
inotify>=0.2.10
|
||||||
gunicorn>=20.0
|
gunicorn>=20.0
|
||||||
django-extensions
|
|
||||||
# development
|
# development
|
||||||
# django-debug-toolbar>=2.2
|
# django-debug-toolbar>=2.2
|
||||||
# django-silk>=4.0
|
# django-silk>=4.0
|
||||||
|
17
test.sh
17
test.sh
@@ -1,17 +0,0 @@
|
|||||||
docker build --tag calibreweb:1.0 . -f ./deployment/Dockerfile
|
|
||||||
docker stop cw
|
|
||||||
docker rm cw
|
|
||||||
docker run --publish 80:80 \
|
|
||||||
-v '/home/MassiveAtoms/Desktop/logs:/app/data' \
|
|
||||||
-v '/home/MassiveAtoms/windows/Users/MassiveAtoms/Documents/Calibre Library/:/app/content' \
|
|
||||||
--name cw calibreweb:1.0
|
|
||||||
sleep 8
|
|
||||||
echo "download/test"
|
|
||||||
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1/download/statictest.txt
|
|
||||||
echo " "
|
|
||||||
echo "/test"
|
|
||||||
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1/statictest.txt
|
|
||||||
echo " "
|
|
||||||
echo "/static/test"
|
|
||||||
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1/static/statictest.txt
|
|
||||||
echo " "
|
|
Reference in New Issue
Block a user