Compare commits

..

No commits in common. "65f919a58f209585f7d027814520482d5beb4898" and "6e2e5ffa00853f4d8d9534911302f55fe5ae80fa" have entirely different histories.

7 changed files with 63 additions and 65 deletions

View File

@ -24,37 +24,6 @@ steps:
password:
from_secret: pypi_pwd
- name: push
image: appleboy/drone-scp
settings:
host:
from_secret: ssh_host
username:
from_secret: ssh_user
key:
from_secret: ssh_key
source:
- dist/morss-*.tar.gz
- morss-helper
target:
- /root
- /usr/bin/local
- name: deploy
image: appleboy/drone-ssh
settings:
host:
from_secret: ssh_host
username:
from_secret: ssh_user
key:
from_secret: ssh_key
script_stop: true
script:
- sudo pip install --upgrade /root/morss-*.tar.gz[full]
- sudo rm /root/morss-*.tar.gz
- sudo morss-helper reload
trigger:
branch:
- master
@ -91,3 +60,37 @@ trigger:
depends_on:
- test
---
kind: pipeline
name: ssh
clone:
disable: true
steps:
- name: deploy
image: appleboy/drone-ssh
settings:
host:
from_secret: ssh_host
username:
from_secret: ssh_user
key:
from_secret: ssh_key
script_stop: true
script:
- sudo pip install --upgrade morss[full]
- "pid=$$(sudo pidof 'gunicorn: master [morss]')"
- sudo kill -s USR2 $$pid
- sudo kill -s WINCH $$pid
- sudo kill -s TERM $$pid
trigger:
branch:
- master
event:
- push
depends_on:
- python

View File

@ -10,5 +10,5 @@ RUN set -ex; \
USER 1000:1000
ENTRYPOINT ["/bin/sh", "/app/morss-helper"]
ENTRYPOINT ["/bin/sh", "/app/docker-entry.sh"]
CMD ["run"]

View File

@ -159,7 +159,6 @@ packages:
write_files:
- path: /etc/environment
append: true
content: |
DEBUG=1
CACHE=diskcache
@ -168,10 +167,9 @@ write_files:
permissions: 744
content: |
#!/bin/sh
/app/morss-helper
gunicorn --bind 0.0.0.0:${PORT:-8000} --preload --access-logfile - --daemon morss
runcmd:
- source /etc/environment
- update-ca-certificates
- iptables -I INPUT 6 -m state --state NEW -p tcp --dport ${PORT:-8000} -j ACCEPT
- netfilter-persistent save
@ -276,30 +274,8 @@ For this, you need to make sure your host allows python script execution. This
method uses HTTP calls to fetch the RSS feeds, which will be handled through
`mod_cgi` for example on Apache severs.
Please pay attention to `main.py` permissions for it to be executable. See below
some tips for the `.htaccess` file.
```htaccess
Options -Indexes
ErrorDocument 404 /cgi/main.py
# Turn debug on for all requests
SetEnv DEBUG 1
# Turn debug on for requests with :debug in the url
SetEnvIf Request_URI :debug DEBUG=1
<Files ~ "\.(py|pyc|db|log)$">
deny from all
</Files>
<Files main.py>
allow from all
AddHandler cgi-script .py
Options +ExecCGI
</Files>
```
Please pay attention to `main.py` permissions for it to be executable. Also
ensure that the provided `/www/.htaccess` works well with your server.
### As a CLI application

6
morss-helper → docker-entry.sh 100755 → 100644
View File

@ -6,12 +6,6 @@ if [ "$1" = "sh" ] || [ "$1" = "bash" ]; then
elif [ -z "$1" ] || [ "$@" = "run" ]; then
gunicorn --bind 0.0.0.0:${PORT:-8000} --preload --access-logfile - morss
elif [ "$@" = "reload" ]; then
pid=$(sudo pidof 'gunicorn: master [morss]')
kill -s USR2 $pid
kill -s WINCH $pid
kill -s TERM $pid
else
morss $@

View File

@ -30,6 +30,7 @@ setup(
data_files = [
('share/' + package_name, ['README.md', 'LICENSE']),
('share/' + package_name + '/www', glob('www/*.*')),
('share/' + package_name + '/www/cgi', [])
],
entry_points = {
'console_scripts': [package_name + '=' + package_name + '.__main__:main']

15
www/.htaccess 100644
View File

@ -0,0 +1,15 @@
Options -Indexes
ErrorDocument 403 "Access forbidden"
ErrorDocument 404 /cgi/main.py
ErrorDocument 500 "A very nasty bug found his way onto this very server"
# Uncomment below line to turn debug on for all requests
#SetEnv DEBUG 1
# Uncomment below line to turn debug on for requests with :debug in the url
#SetEnvIf Request_URI :debug DEBUG=1
<Files ~ "\.(py|pyc|db|log)$">
deny from all
</Files>

View File

@ -0,0 +1,9 @@
order allow,deny
deny from all
<Files main.py>
allow from all
AddHandler cgi-script .py
Options +ExecCGI
</Files>