Skip to content

Commit 956f0a8

Browse files
committed
ability to run with custom checker/collectors
1 parent a364585 commit 956f0a8

File tree

2 files changed

+97
-7
lines changed

2 files changed

+97
-7
lines changed

README.rst

+62-7
Original file line numberDiff line numberDiff line change
@@ -226,39 +226,94 @@ anything, just run
226226
227227
inside virtual environment in proxy_py project directory.
228228

229+
How to use custom checkers/collectors?
230+
**************************************
231+
232+
If you wan't to collect proxies from your source or you need proxies to work with particular site,
233+
you can write your own collectors or/and checkers.
234+
235+
1. Create your checkers/collectors in current directory following the next directory structure:
236+
237+
// TOOD: add more detailed readme about it
238+
239+
```
240+
241+
local/
242+
├── requirements.txt
243+
├── checkers
244+
│   └── custom_checker.py
245+
└── collectors
246+
   └── custom_collector.py
247+
248+
```
249+
250+
You can create only checker or collector if you want so
251+
252+
2. Create `proxy_py/settings.py` in current dir with the following content
253+
254+
```python3
255+
256+
from ._settings import *
257+
from local.checkers.custom_checker import CustomChecker
258+
259+
PROXY_CHECKERS = [CustomChecker]
260+
261+
COLLECTORS_DIRS = ['local/collectors']
262+
263+
```
264+
265+
you can append your checker to PROXY_CHECKERS or COLLECTORS_DIRS instead of overriding to use built in ones as well, it's just normal python file.
266+
See `proxy_py/_settings.py` for more detailed instructions on options.
267+
268+
3. Follow the steps in "How to install?" but download this docker-compose config instead
269+
270+
```bash
271+
wget "https://raw.githubusercontent.com/DevAlone/proxy_py/master/docker-compose-with-local.yml"
272+
```
273+
274+
and run with command
275+
276+
```bash
277+
docker-compose -f docker-compose-with-local.yml up
278+
```
279+
280+
4. ...?
281+
282+
5. Profit!
283+
229284
How to build from scratch?
230285
**************************
231286

232-
1 Clone this repository
287+
1. Clone this repository
233288

234289
.. code-block:: bash
235290
236291
git clone https://github.com/DevAlone/proxy_py.git
237292
238-
2 Install requirements
293+
2. Install requirements
239294

240295
.. code-block:: bash
241296
242297
cd proxy_py
243298
pip3 install -r requirements.txt
244299
245-
3 Create settings file
300+
3. Create settings file
246301

247302
.. code-block:: bash
248303
249304
cp config_examples/settings.py proxy_py/settings.py
250305
251-
4 Install postgresql and change database configuration in settings.py file
306+
4. Install postgresql and change database configuration in settings.py file
252307

253-
5 (Optional) Configure alembic
308+
5. (Optional) Configure alembic
254309

255-
6 Run your application
310+
6. Run your application
256311

257312
.. code-block:: bash
258313
259314
python3 main.py
260315
261-
7 Enjoy!
316+
7. Enjoy!
262317

263318

264319
Mirrors

docker-compose-with-local.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: '3'
2+
3+
services:
4+
db:
5+
image: "postgres:12"
6+
restart: always
7+
environment:
8+
- POSTGRES_USER=proxy_py
9+
- POSTGRES_PASSWORD=proxy_py
10+
- POSTGRES_DB=proxy_py
11+
volumes:
12+
- db_data:/var/lib/postgresql/data
13+
- ./init_db.sql:/docker-entrypoint-initdb.d/init_db.sql
14+
core:
15+
image: "devalone/proxy_py:latest"
16+
command: >
17+
bash -c "
18+
source /proxy_py/env/bin/activate &&
19+
pip3 install -r /proxy_py/local/requirements.txt &&
20+
/proxy_py/run.sh
21+
"
22+
restart: always
23+
ports:
24+
- "55555:55555"
25+
environment:
26+
- PROXY_PY_PROXY_PROVIDER_SERVER_ADDRESS={'HOST':'0.0.0.0','PORT':55555}
27+
- PROXY_PY_DATABASE_CONNECTION_KWARGS={'host':'db','database':'proxy_py','user':'proxy_py','password':'proxy_py'}
28+
depends_on:
29+
- db
30+
volumes:
31+
- ./local/:/proxy_py/local/
32+
- ./proxy_py/settings.py:/proxy_py/proxy_py/settings.py
33+
34+
volumes:
35+
db_data:

0 commit comments

Comments
 (0)