server

command
v0.0.0-...-bf2171b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2015 License: MIT Imports: 5 Imported by: 0

README

The server components run on a separate machine/network and support the functions of the Raspberry Pi scanner, particularly the barcode lookup.

By default, the Pi client talks to the API service on the saruzai.com server, which runs a MySQL database clone of the last available Open Product Data (POD) data, along with additional tables for logging user contributions.

If you do not wish to participate in that project, you can build and run your own server instead, by following these instructions.

Initial server preparation

These instructions assume the underlying OS is debian linux. If you want to use something else, you will need to make the necessary pkg and configuration changes.

  1. Basic packages using apt as root/sudo:
# apt-get update; apt-get upgrade -y
# apt-get install -y git mercurial build-essential python-all-dev python-lxml python-magic python-pip python-pycurl screen
# pip install python-amazon-product-api
# adduser pod 
  1. POD-specific setup as the pod user:
$ mkdir data
$ cd data
$ wget http://www.product-open-data.com/docs/pod_web_2014.01.01_01.sql.gz
$ gunzip pod_web_2014.01.01_01.sql.gz
$ mysqladmin -u root -p create product_open_data
$ mysql -u root -p product_open_data < pod_web_2014.01.01_01.sql
$ mysql -u root -p product_open_data < piscan_tables.sql
$ mysql -u root -p product_open_data < piscan_user.sql
$ mysql -u pod product_open_data

The piscan_tables.sql file is a convenience (in lieu of invoking mysql over each sql file) prepared by combining all the additional tables from this repo, like this:

$ cat contributors.sql products.sql commerce.sql books.sql >piscan_tables.sql

The piscan_user.sql file is defined as:

CREATE USER 'pod'@'localhost';
GRANT ALL PRIVILEGES ON *.* TO 'pod'@'localhost'
WITH GRANT OPTION;
FLUSH PRIVILEGES;

Server application installation

These steps are for the saruzai.com server; please change your domain or IP address accordingly.

  1. Prepare the server environment

As the pod user:

$ cd /home/pod
$ mkdir -p server/commerce/amazon/
  1. Copy the Amazon API scripts
scp server/commerce/amazon/*.py pod@saruzai.com:/home/pod/server/commerce/amazon

Optionally, login as the pod user and create a amazon_local_settings.py file, which defines your own Amazon API coordinates.

$ cd server/commerce/amazon/
$ vi amazon_local_settings.py

As described here, the amazon_local_settings.py file overrides the default (empty) settings for the access and secret keys.

  1. Download the APIServer binary to the server
scp APIServer pod@saruzai.com:/home/pod/server

This link is a linux/amd64 binary. If your server is different, you must build from source instead.

  1. APIServer startup script

Copy the api-server.sh script to the server:

cd server/init.d
scp api-server.sh pod@saruzai.com:/tmp                                                     

Then, as root/sudo, move it to /etc/init.d with the correct permissions, and install via update-rc.d to start automatically on boot:

# mv /tmp/api-server.sh /etc/init.d
# chmod 755 /etc/init.d/api-server.sh
# update-rc.d api-server.sh defaults

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
database

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL