diff --git a/.gitignore b/.gitignore index cdc52ec..ecac2b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,10 @@ env/ venv/ venv/* +.idea/ +__pycache__/ +__pycache__/* +app/__pycache__/ +app/__pycache__/* +app/static/dewatermark/ +app/static/dewatermark/* \ No newline at end of file diff --git a/README.md b/README.md index e69de29..75ae627 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,88 @@ +# Run + +## in Development +`export FLASK_APP=run.py` +`export FLASK_ENV=development` +`flask run` + +**Using gunicorn:** + +`gunicorn --env SCRIPT_NAME=/watermarks -w 4 -b 127.0.0.1:5000 app:app --log-level debug` +* `-w` workers +* `-b` bind to address / unix socker + +**And gunicorn with using unix sock:** (this how it should run in production) +` gunicorn --env SCRIPT_NAME=/watermarks --workers 4 --bind unix:app.sock -m 007 app:app --log-level debug + +## in Production with gunicorn and unix sockets +Based on https://medium.com/faun/deploy-flask-app-with-nginx-using-gunicorn-7fda4f50066a + +### systemd service file + +Add to /etc/systemd/system/watermarks.service + +``` +[Unit] +After=network.target + +[Service] +User=psc +Group=www-data +WorkingDirectory=/var/www/TacticalApp +Environment="PATH=/var/www/TacticalApp/venv/bin" +ExecStart=/var/www/TacticalApp/venv/bin/gunicorn --env SCRIPT_NAME=/watermarks --workers 4 --bind unix:app.sock -m 007 app:app + +[Install] +WantedBy=multi-user.target +``` + +## enable & start service file +`systemctl enable watermarks.service` + +`systemctl start watermarks.service` + +It is also a good idea to check the status of the service +`systemctl status watermarks.service` + +## Nginx config + +``` +location / { + # if using gunicorn with app sock, use: + proxy_pass http://unix:/var/www/TacticalApp/app.sock; + # if using gunicord with port 5000, use: + proxy_pass http://127.0.0.1:5000; + } +``` + +## debug. + +It might be helpful to enable gunicorn logging, while in development, to check what is going on, + by replacing in watermarks.service, the `ExecStart=` value with: + +`ExecStart=/var/www/TacticalApp/venv/bin/gunicorn --log-level debug --error-logfile /var/www/TacticalApp/app.log --workers 4 --bind unix:app.sock -m 007 app:app` + +And reloading the services +`systemctl daemon-reload` + +`systemctl restart watermarks.service` + +and the start following app.log: +`tail -f /var/www/TacticalApp/app.log` + +But in the long run logging should be disabled + +---- +09.06.2020 Handling url path /watermarks + +* gunicorn has to be started with argument `--env SCRIPT_NAME=/watermarks` which defines its path: +`gunicorn --env SCRIPT_NAME=/watermarks --workers 4 --bind unix:app.sock -m 007 app:app --log-level debug` + * allows for the following URLs + * http://127.0.0.1/watermarks + * http://127.0.0.1/watermarks/uploadbook + * http://127.0.0.1/watermarks/about + +* added page /test `watermarks/test` for testing url_for() - correct +* made urls relative +* service file with `--env SCRIPT_NAME=/watermarks` see above +* diff --git a/__pycache__/config.cpython-37.pyc b/__pycache__/config.cpython-37.pyc deleted file mode 100644 index 657ef5b..0000000 Binary files a/__pycache__/config.cpython-37.pyc and /dev/null differ diff --git a/app/__pycache__/__init__.cpython-37.pyc b/app/__pycache__/__init__.cpython-37.pyc deleted file mode 100644 index 58d9b24..0000000 Binary files a/app/__pycache__/__init__.cpython-37.pyc and /dev/null differ diff --git a/app/__pycache__/views.cpython-37.pyc b/app/__pycache__/views.cpython-37.pyc deleted file mode 100644 index 5715495..0000000 Binary files a/app/__pycache__/views.cpython-37.pyc and /dev/null differ diff --git a/app/templates/public/404.html b/app/templates/public/404.html index 455f5c6..9b19082 100644 --- a/app/templates/public/404.html +++ b/app/templates/public/404.html @@ -12,7 +12,7 @@
Here you can upload a file that will be republished to Library Genesis. We take care of the whole process of republishing. Your book should not have watermarks. They will not be removed.
-We will also create a uploaders signature, read more about it here! Please feel free to leave your remarks on the process of sharing the file. If you want to batch upload, please contact me directly!
+We will also create a uploaders signature, read more about it here! Please feel free to leave your remarks on the process of sharing the file. If you want to batch upload, please contact me directly!