Skip to content

unclechu/avto-lux161

 
 

Repository files navigation

avto-lux161

WARNING

Project was left in the middle of refactoring process, it most likely in a broken state. Changes just stored to archive it, it's not planned to work on this project anymore.

How to deploy

  1. Clone this repo and go to the cloned directory:
$ git clone https://github.com/web-izmerenie/avto-lux161 avto-lux161
$ cd avto-lux161
  1. Install git-submodules:
$ git submodule update --init
  1. Create Python virtual environment and activate it:
$ pyvenv .venv
$ source ./.venv/bin/activate
  1. Install Python requirements:
$ pip3 install -r requirements.txt
  1. Copy config.yaml.example to config.yaml and set in config.yaml:

  2. DATABASE — set correct access data to database. According to this guide:

```yaml
DATABASE:
  HOST: 'localhost'
  PORT: ''
  DBNAME: 'avtolux_dbname'
  USER: 'avtolux_user'
  PASS: 'avtolux_password'
  TABLE_NAME_PREFIX: 'avtolux_'
```
  1. DEV_SERVER — if you going to start development server;

  2. PRODUCTION_SERVER — if you going to start production server.
    WARNING!: don't set instances more than 1, cause it isn't supported yet, need some debug for errors;

  3. DEBUG — set to 1 if you wan't more debug info.

  4. Copy ./files/uploaded/ dir from backup archive to ./files/uploaded/.

Just for example, doing it by extracting from backup (you should be inside root of the project and backup should be placed there too):

$ cd files
$ tar -xzf ../avtolux_files_backup_20150308050634.tar.gz --strip-components=1 files/uploaded/

Or if you don't have any backups skip this item and go to the next one.

  1. Fill database by database dump from backup archive:

If you have started without any backups read this and skip this item.

$ cat avtolux_db_dump_20150308041213.sql.gz | gunzip | psql -h localhost -d avtolux_dbname -U avtolux_user

Where avtolux_db_dump_20150308041213.sql.gz is database dump, avtolux_user is user for database access and avtolux_dbname is a database name;

  1. Install npm dependencies and build some front-end stuff:
$ npm install

And build optimized production front-end bundles:

$ npm run bundle-production

Or build pretty development bundles and start watcher for development:

$ npm run bundle-development-client
$ npm run bundle-development-admin

It uses webpack for bundling, you can run just this project local webpack executable by this command:

$ npm run webpack

See for scripts key in package.json, also you can call webpack with specific arguments through --, for example show webpack help:

$ npm run webpack -- --help
  1. Run web-server:

In debug mode:

$ ./run_development.sh

Or in production mode:

$ ./run_production.sh

Useful information

Pull last revision

After pull fresh revision from git don't forget to run:

$ ./migrate.sh

It automatically checks what migrations needed and then apply them, or it will do nothing if all migrations already applied.

Deploy with clean database

May be you wan't to know how to create new database and new user to access this database? Then read this first.

$ ./avto-lux/manage.py dbsync

And then create new admin user:

$ ./avto-lux/manage.py create-admin

It will create accout with login admin and password admin.
WARNING! Do not foget to go later to /adm/ route and change this login/password!

Now you can start development:

$ ./run_development.sh

Or production (doesn't matter):

$ ./run_production.sh

Don't be afraid of 500 error, because we don't have main page yet.

After that you can go to /adm/#panel/pages route and create main page (page with path /).

Now it would be good to add some data fields that used on site, go to route /adm/#panel/data/add.html and create this fields (for name field in every level just use any useful human-name and use number value for sort, main key is symbol key):

  1. phones: 1. header text (multiple) 2. footer text (single)

  2. email: 1. footer text (single)

  3. counters: 1. bottom_counters multiline text (multiple)

  4. robots: 1. robots multiline text (single) with value:

    User-agent: *
    Disallow: /adm/
    Disallow: /static/admin-templates/
    Disallow: /static/ckeditor/

Prepare new database

Login as postgres user:

$ sudo su - postgres

Then open interactive PostgreSQL terminal:

$ psql

Inside that terminal create new user: named as avtolux_user with password avtolux_password:

create user avtolux_user with password 'avtolux_password' ;

After that create new database named as avtolux_dbname:

create database avtolux_dbname ;

And give user created before all privileges to this new database:

grant all on database avtolux_dbname to avtolux_user ;

You can check if it's done:

\l

Done!

How to make backup

Database dump

$ pg_dump -h localhost -d avtolux_dbname -U avtolux_user | gzip > avtolux_db_dump_`date +'%Y%m%d%H%M%S'`.sql.gz

Where avtolux_user is user for database access and avtolux_dbname is a database name;

Uploaded files backup

Inside root of the project:

$ tar -czvf avtolux_files_backup_`date +'%Y%m%d%H%M%S'`.tar.gz files/uploaded/

Packages

No packages published

Languages

  • LiveScript 43.3%
  • Python 34.3%
  • CSS 12.9%
  • HTML 7.9%
  • JavaScript 1.4%
  • Shell 0.2%