Skip to content

Commit 04308b8

Browse files
authored
Merge pull request #483 from ispras/heavy_refactor
Version 2.0 alpha
2 parents dab1f1c + 8b00c49 commit 04308b8

File tree

534 files changed

+548293
-454509
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

534 files changed

+548293
-454509
lines changed

.gitignore

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,13 @@ venv/
99
*.pyc
1010
webui/node_modules/
1111
webui/bower_components/
12-
webui/.sass-cache/
12+
webui/.sass-cache/
13+
14+
# build stuff
15+
dist/
16+
build/
17+
lingvodoc.egg-info/
18+
alembic.ini
19+
20+
# webui2
21+
target/

README.md

Lines changed: 114 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ LingvoDoc is intended to provide natural language documentation service as Web-s
77
ajax-based client application.
88

99

10-
Dependancies
10+
Dependencies
1111
---------------
1212

1313
- pyramid (framework)
1414

1515
- sqlalchemy (ORM)
1616

17+
- RDBMS compatible with sqlalchemy
18+
1719

1820
Running the project for development
1921
---------------
@@ -24,9 +26,17 @@ Running the project for development
2426

2527
- cd <directory containing this file>
2628

27-
- create development.ini from production.ini (change sqlalchemy.url)
29+
- launch every command from this directory
30+
31+
- create database
2832

29-
- create alembic.ini from alembic_base.ini (change sqlalchemy.url)
33+
- create development.ini from production.ini. You must set at least sqlalchemy.url pointing to
34+
created database
35+
36+
- create alembic.ini from alembic_base.ini. Again, you must set at least sqlalchemy.url pointing to
37+
created database
38+
39+
- pip install -r requirements.txt
3040

3141
- $VENV/bin/python setup.py develop
3242

@@ -36,6 +46,107 @@ Running the project for development
3646

3747
- $VENV/bin/pserve development.ini
3848

49+
Example for PostgreSQL:
50+
51+
```
52+
# from psql:
53+
drop database lingvodoc; -- drop old database, if exists
54+
create database lingvodoc with owner postgres encoding 'UTF8' LC_COLLATE = 'ru_RU.UTF-8' LC_CTYPE = 'ru_RU.UTF-8' template template0;
55+
# from shell, with activated venv:
56+
pip install -r requirements.txt
57+
# cp production.ini development.ini
58+
# set sqlalchemy.url to postgresql+psycopg2://postgres@/lingvodoc in development.ini
59+
# TODO [app:accounts] add section to development.int?
60+
cp alembic_base.ini alembic.ini # set sqlalchemy.url twice to postgresql+psycopg2://postgres@/lingvodoc
61+
python setup.py develop
62+
alembic upgrade head
63+
initialize_lingvodoc_db development.ini
64+
pserve development.ini
65+
66+
```
67+
68+
Installing as server (full-speed) environment for Ubuntu.
69+
---------------
70+
71+
0. Install (if you do not have one) Python 3.4 or later.
72+
1. Install PostgreSQL server 9.6.
73+
* Ensure that all your locale settings are UTF-8 in your current bash (run `locale` to see it).
74+
* Create file `/etc/apt/sources.list.d/pgdg.list` with `deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main`.
75+
If you are using less recent distro version, replace `xenial` with `trusty` or `precise`.
76+
* Get certificate for this repository: `wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc |
77+
sudo apt-key add -; sudo apt-get update`
78+
* Install PostgreSQL server, dev and contrib: `sudo apt-get install postgresql-9.6 postgresql-server-dev-9.6 postgresql-contrib-9.6`
79+
* Tune up the settings (optional but recommended):
80+
+ (optionally - just for dev purposes - not recommended) in `/etc/postgresql/9.6/main/pg_hba.conf` - `local all postgres trust`
81+
+ in `/etc/postgresql/9.6/main/postgresql.conf`:
82+
* `shared_buffers` - 1/16 of your memory (e.g. for 32GB RAM `shared_buffers = 2048MB`)
83+
* `temp_buffers = 256MB`
84+
* `work_mem` - (total RAM/2*cores count)/8 (e.g. for 32GB RAM and 8 logical cores `work_mem = 256MB`)
85+
* `maintenance_work_mem` = 2*work_mem (e.g. `maintenance_work_mem = 512MB`)
86+
* `max_stack_depth = 6MB`
87+
* `max_wal_senders = 10`
88+
* `effective_cache_size` - 1/8 of total RAM (e.g. 4096MB)
89+
* `wal_level = replica`
90+
* Restart postgres: `sudo service postgresql restart`
91+
* Import the latest database backup (from-scratch creation look in `# from psql` section): `sudo -u posgres psql < lingvodoc.sql`
92+
2. Install Redis: `sudo apt-get install redis-server`.
93+
3. Install compilers, libraries and git: `sudo apt-get install build-essential python3-dev libssl-dev git`
94+
4. Install venv-creator: `sudo apt-get install python3-virtualenv`
95+
5. (optional but recommended) Create separate regular user (without sudo permissions) for Lingvodoc system.
96+
If you use this step, login as that user for all the other steps.
97+
6. Go to your home dir and create venv:
98+
`cd ~; mkdir -p environments; python3 -m virtualenv -p python3 ./environments/lingvodoc-server`
99+
7. Activate your virtualenv: `source ./environments/lingvodoc-server/bin/activate`
100+
8. Clone lingvodoc repository and checkout the correct branch: `git clone https://github.com/ispras/lingvodoc`
101+
9. Execute `cd lingvodoc; pip3 install -r server-requirements.txt`
102+
10. Go into lingvodoc dir and make `python setup.py install` or `python setup.py develop` (you should know what you are doing)
103+
11. Copy alembic_base.ini and postgres.ini configs to home directory: `cp ./alembic_base.ini ../ ; cp postgres.ini ../`
104+
12. Tuneup settings in alembic_base.ini:
105+
* sqlalchemy.url
106+
13. Tuneup settings in postgres.ini:
107+
* section [server:main] according to your choice. Recommended way to deploy in production mode is to use gunicorn (or uwsgi but it may have some problems)
108+
```
109+
[server:main]
110+
use = egg:gunicorn#main
111+
workers = 8
112+
timeout = 3000
113+
proc_name = lingvodoc
114+
bind = unix:/tmp/lingvodoc.sock
115+
```
116+
(note: you should install gunicorn to use that config; it's not present in requirements since pserve/waitress works well too)
117+
(note2: if you are using that way, you will need wsgi-frontend [nginx for example])
118+
* section [app:main]
119+
- `secret = 'your random string'`
120+
- `sqlalchemy.url` according to database name, postgres port etc.
121+
* loggers (to your choice)
122+
* section [app:accounts] for your administrator user (needed for building from scratch)
123+
* section [backend:storage]. WARNING: do not forget to change `prefix`
124+
- in case of plain disk usage:
125+
```
126+
[backend:storage]
127+
type = disk
128+
path = /home/lingvodoc/objects/
129+
prefix = http://lingvodoc.ispras.ru/
130+
static_route = objects/
131+
```
132+
- in case of Openstack Swift usage (just for example; you must know what you are doing if you use it):
133+
```
134+
[backend:storage]
135+
authurl = http://10.10.10.121:5000/v2.0
136+
store = http://adelaide.intra.ispras.ru/horizon/project/containers
137+
user = admin
138+
key = tester
139+
auth_version = 2.0
140+
tenant_name = admin
141+
```
142+
14. Run lingvodoc: `pserve --daemon ./postgres.ini start`
143+
144+
145+
Installing as desktop (user) environment for Ubuntu
146+
---------------
147+
(Will be reported later)
148+
149+
39150
API documentation
40151
---------------
41152

alembic/env.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ def run_migrations_online():
6565
with context.begin_transaction():
6666
context.run_migrations()
6767

68-
if context.is_offline_mode():
69-
run_migrations_offline()
70-
else:
71-
run_migrations_online()
68+
def upgrade():
69+
if context.is_offline_mode():
70+
run_migrations_offline()
71+
else:
72+
run_migrations_online()
73+
74+
upgrade()

0 commit comments

Comments
 (0)