-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreader.yaml
171 lines (144 loc) · 4.67 KB
/
reader.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# should work with Ubuntu 18.04.2 LTS
# TODO: run sudo apt-get update first
- hosts: all
gather_facts: no
become: true
become_method: sudo
tasks:
- name: create apps directory
file:
path: /apps
state: directory
- name: install uwsgi
package:
name: "{{ item }}"
state: latest
loop:
- uwsgi
- uwsgi-plugin-python3
# TODO: stop uwsgi reader service, remove from nginx, remove virtualenv
- name: install venv
package:
name: python3-venv
state: latest
- name: create virtualenv with the latest pip
pip:
name: pip
virtualenv: /apps/reader
virtualenv_command: /usr/bin/python3 -m venv
virtualenv_site_packages: yes
state: latest
- name: install reader
pip:
name:
- pip
- "git+https://github.com/lemon24/reader.git#egg=reader[cli,app,enclosure-tags,preview-feed-list,plugins,search]"
virtualenv: /apps/reader
state: latest
- name: create database directory
file:
path: /data/www-data
state: directory
owner: www-data
- name: enable reader search
shell: LC_ALL=en_US.utf-8 /apps/reader/bin/python -m reader --db /data/www-data/reader.sqlite search enable
- name: update reader search once
shell: LC_ALL=en_US.utf-8 /apps/reader/bin/python -m reader --db /data/www-data/reader.sqlite search update
# TODO: should use emperor
- name: create uwsgi config file
copy:
dest: /apps/reader/uwsgi.ini
content: |
[uwsgi]
socket = /apps/reader/uwsgi/sock
manage-script-name = true
mount = /reader=reader._app.wsgi:app
plugin = python3
virtualenv = /apps/reader/
env = READER_DB=/data/www-data/reader.sqlite
env = READER_PLUGIN=reader._plugins.enclosure_dedupe:enclosure_dedupe
env = READER_APP_PLUGIN=reader._plugins.enclosure_tags:init reader._plugins.preview_feed_list:init
plugins = carbon
carbon = 127.0.0.1:1111
#enable-metrics = true
#carbon-use-metrics = true
carbon-id = reader
carbon-hostname-dots = -
# TODO: permissions
- name: create uwsgi socket dir
file:
path: /apps/reader/uwsgi
state: directory
owner: www-data
- name: create uwsgi reader service
copy:
dest: /etc/systemd/system/uwsgi_reader.service
content: |
[Unit]
Description=uwsgi reader
After=syslog.target
[Service]
User=www-data
ExecStart=/bin/sh -c '/usr/bin/uwsgi --ini /apps/reader/uwsgi.ini'
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
- name: restart uwsgi reader service
service:
name: uwsgi_reader
state: restarted
enabled: yes
# TODO: find a way to make this independent of the python3 version
- name: add nginx config
copy:
dest: /etc/nginx/secure/reader.conf
content: |
location /reader/ {
include uwsgi_params;
uwsgi_pass unix:/apps/reader/uwsgi/sock;
}
location = /reader { rewrite ^ /reader/; }
location /reader/static/ {
alias /apps/reader/lib/python3.6/site-packages/reader/_app/static/;
}
- name: reload nginx config
command: nginx -s reload
- name: create log directory
file:
path: /var/log/reader
state: directory
owner: www-data
- name: add crontab entry to update all feeds
cron:
name: "reader update {{ item }}"
user: www-data
special_time: "{{ item }}"
job: >
LC_ALL=en_US.utf-8
READER_PLUGIN='reader._plugins.tumblr_gdpr:tumblr_gdpr reader._plugins.regex_mark_as_read:regex_mark_as_read reader._plugins.feed_entry_dedupe:feed_entry_dedupe'
/apps/reader/bin/python -m reader
--db /data/www-data/reader.sqlite update -v
>>/var/log/reader/update.log 2>&1
loop:
- hourly
- reboot
- name: add crontab entry to update new feeds and the search index
cron:
name: reader update new
user: www-data
job: >
LC_ALL=en_US.utf-8
READER_PLUGIN='reader._plugins.tumblr_gdpr:tumblr_gdpr reader._plugins.regex_mark_as_read:regex_mark_as_read reader._plugins.feed_entry_dedupe:feed_entry_dedupe'
/apps/reader/bin/python -m reader
--db /data/www-data/reader.sqlite update --new-only -v
>>/var/log/reader/update.log 2>&1
&&
LC_ALL=en_US.utf-8
/apps/reader/bin/python -m reader
--db /data/www-data/reader.sqlite search update
>>/var/log/reader/update.log
# TODO: backup database to s3