Skip to content

Server and content importers for the Bodega content system.

Notifications You must be signed in to change notification settings

KDE/bodega-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

System Requirements
===================
The Bodega server requires the following software to be installed on the system prior to use:

* node.js (0.10 or better)
* PostgreSQL (v9.1 or better)
* Redis (used for user session data)
* GraphicsMagick (used to manipulate images uploaded for icons, covers, previews, etc)

The following optional packages may be installed for additional functionality:

* Discourse, for participant feedback and discussion

Server Setup
============
All commands that follow are done relative to the server/ directory and the instructions should
be followed in the order presented.

## Configuration

Copy the config.json.sample file to config.json and customize the values within it. The configuration
keys should be self-explanatory, and if you do not use a given service (e.g. Stripe) you can
safely ignore those blocks completely.

Most of the default settings should work as-is, though some such as the hostname and external URL
settings probably need to be changed for production use. Email settings also need changing for
email to be sent out; the email block follows the options for nodemailer:

    https://github.com/andris9/Nodemailer

To adjust the type of content and rules for assets you can make adjustments to the definitions in
server/assetRules.js as well as in the default dataset in sql/defaultdata.sql. The latter must be
done before running `make sql` or else be loaded by hand.

## Node setup and module Installation

The npm application takes care of installation of all the required modules, which are listed in the
package.json file. Simply run:

   $ npm install

You may need to install the nodejs-devel package for your operating system to build some of
the modules, such as bcrypt and pg.

## Database setup

* Start the redis daemon (e.g.: /etc/init.d/redis start)
* Ensure that postgresql is configured to retrieve dates in UTC by default. This is done by
  editing postgresql.conf and ensuring "timezone = 'utc'" (it defaults to "posixrules")
* Ensure that the hstore postgresql extension is installed; this may be part of the postgres-contrib
  package of the OS.
* Start the postgresql daemon (e.g.: /etc/init.d/postgresql start)

Note that if you are using an OS that uses systemd, you may not have init.d files. In which
case you can start postgresql and redis like this:

   $ systemctl start postgresql.service
   $ systemctl start redis.service

You can also ensure that these services are always started with `systemctl enable`

* Next, create a bodega user in postgresql:

   $ su postgres -c "createuser bodega"

The 'bodega' user does not need to be a super user, able to create databases or modify roles.
If you changed the service.database.user setting in config.json from "bodega", use that name
in the above command rather than the default "bodega".

* Finally, in the server/ directory, run the following command:

   $ make sql

and follow the directions on screen. Output should inform you of each step being processed.

## Optional: Discusssion module

User feedback and discussion is provided using the Discourse server, which can be found here:

    http://www.discourse.org/

To support integration with Bodega, we maintain a patch set on top of Discourse on github.
Start by cloning the discourse repository that contains these patches somewhere on disk,
preferably separate from the bodega server root:

    git clone https://github.com/aseigo/discourse.git
    cd discourse

Next, switch to the latest "bodega" branch which contains the bodega integration patches:

    git checkout bodega_v0.9.7

You can get a list of all available bodega integration branches with this commend:

    git branch -r | grep bodega

Next, set up the discourse installation itself, following the instructions found here:

    https://github.com/discourse/discourse/blob/master/docs/INSTALL-ubuntu.md

(The instructions work for distributions other than Ubuntu.)

Finally, ensure that the settings for the discourse database in
bodega-server/server/config.json are set correctly.

## Starting the server

To start the bodega server in testing mode, run:

   $ ./main.sh

You can also start it directly with:

   $ node app.js

though that is generally not recommended. Using the main.sh: it is a future proof habit to get into.

To start it in production mode, do:

    $ ./main.sh production

This relies on the node.js "forever" package being installed.

## Updating

    $ npm update

Updates to sql schemas, if necesary, will be found in in sql/updates with file names ordered in a
numerically ascending sequence.

To update the database when changes occur, do:

    $ cd server
    $ make update_sql

This will run any update scripts in sql/updates/ that have not yet been run. To run a script again,
either load it manually via the psql command into the bodega database or edit (or remove) the
sql/updates/completed file which records which updates have been applied. Errors while running
updates are usually fine and simply mean that the changes were already found in the database.

## Testing

To set up the server for running the tests, first ensure that you have a database set up just for
testing as the tests rely on test data set which replaces whatever data may otherwise be in the
database. In other words: do not run the tests on a production system and expect things to go well.

To load the testing data set:

    $ cd server
    $ make test_sql

Then run the test suite:

    $ make test

You can also run individual test suites with:

    $ make test/<testname>

<testname> is the name of the .js file in the tests/ directory minus the .js extenstion, so for
example:

   $ make test/upload

## Checking the code

We use jshint to check for common js errors and style issues.
Use a simple.

   $ make check

The configuration is stored in the .jshintrc file and the files which should be skipped are stored in the .jshintignore .

Asset Importers
===============
These small command line, Qt-based helpers automate the processes of getting external
catalogs and importing them locally.

Configure and install with:

cmake -DBODEGA_BUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX=/opt/something /bodega/src