Setting up a production instance of Toaster: Difference between revisions

From Yocto Project
Jump to navigationJump to search
No edit summary
No edit summary
Line 1: Line 1:
[[Category:Toaster]]
[[Category:Toaster]]


A production instance of Toaster is one in which you wish to share the Toaster instance with multiple users. It is also the setup which can cope with heavier loads on the web service.
A production instance of Toaster is one in which you wish to share the Toaster instance with remote and multiple users. It is also the setup which can cope with heavier loads on the web service. These instructions setup toaster in Build mode where builds and projects are run, viewed and defined by the Toaster web interface.


=== Requirements ===
== Requirements ==
* [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html#packages Build requirements]
* [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html#packages Build requirements]
* Apache webserver
* Apache webserver
Line 11: Line 11:
Ubuntu 14.04.3:
Ubuntu 14.04.3:
<code>
<code>
     $ sudo apt-get install apache2 libapache2-mod-wsgi mysql-server virtualenv
     $ sudo apt-get install apache2 libapache2-mod-wsgi mysql-server virtualenv libmysqlclient-dev
</code>
</code>


Fedora 22/RH:
Fedora 22/RH:
<code>
<code>
     $ sudo dnf install httpd mod_wsgi python-virtualenv
     $ sudo dnf install httpd mod_wsgi python-virtualenv gcc mysql-devel
</code>
</code>




=== Installation ===  
== Installation ==


# Checkout a copy of Poky into the web server directory. We're going to be using /var/www/toaster.
'''1. Checkout a copy of Poky into the web server directory. We're going to be using /var/www/toaster.'''
<code>
<code>
   $ mkdir -p /var/www/toaster
   $ mkdir -p /var/www/toaster
Line 30: Line 30:
</code>
</code>


# Initialise a virtualenv and install Toaster dependencies to keep the python packages isolated from your system provided packages - not required but recommended
'''2. Initialise a virtualenv and install Toaster dependencies. (Use virtualenv to keep the python packages isolated from your system provided packages - not required but recommended, alternative use your OS's package manager to install the packages)'''


<code>
<code>
Line 41: Line 41:
</code>
</code>


# Configure toaster edit /var/www/toaster/poky/bitbake/lib/toaster/toastermain/settings.py
'''3. Configure toaster edit /var/www/toaster/poky/bitbake/lib/toaster/toastermain/settings.py'''


Edit the DATABASE settings:
<code>
<code>
  DATABASES = {
  DATABASES = {
Line 55: Line 56:
</code>
</code>


Edit the SECRET_KEY:
<code>
SECRET_KEY = 'YOUR SECRET RANDOM KEY HERE'
</code>


Edit the STATIC_ROOT:
<code>
STATIC_ROOT = '/var/www/toaster/static_files/'
</code>


'''4. Now add the database and user to your mysql server that we just defined'''
<code>
$ mysql -u root -p
mysql> CREATE DATABASE toaster;
mysql> CREATE USER 'toaster'@'localhost' identified by 'yourpasswordhere';
mysql> GRANT all on toaster_data.* to 'toaster'@'localhost';
mysql> quit
</code>
n.b. You may want to decide on fewer [https://dev.mysql.com/doc/refman/5.1/en/grant.html privileges] to the toaster user.


'''5. Get toaster to create the database schema and default data'''


<code>
$ cd  /var/www/toaster/poky/
$ ./bitbake/lib/toaster/manage.py syncdb --migrate
$ ./bitbake/lib/toaster/manage.py loadconf ./meta-yocto/conf/toasterconf.json
$ ./bitbake/lib/toaster/manage.py lsupdates
</code>




# Add a config file for Toaster to your Apache webserver configurations available directory.  
'''6. Add a config file for Toaster to your Apache webserver configurations available directory. '''


Ubuntu/Debian put it here: /etc/apache2/conf-available/toaster.conf
Ubuntu/Debian put it here: /etc/apache2/conf-available/toaster.conf
Line 67: Line 92:
<code>
<code>


  Alias /static /var/www/toaster/static
  Alias /static /var/www/toaster/static_files
  <Directory /var/www/toaster/static>
  <Directory /var/www/toaster/static_files>
  Order allow,deny
  Order allow,deny
  Allow from all
  Allow from all
  Require all granted
  Require all granted
  </Directory>
  </Directory>
  WSGIDaemonProcess toaster_wsgi python-path=/var/www/toaster/toaster-next/bitbake/lib/toaster:/var/www/toaster /venv/lib/python2.7/site-packages
  WSGIDaemonProcess toaster_wsgi python-path=/var/www/toaster/toaster-next/bitbake/lib/toaster:/var/www/toaster /venv/lib/python2.7/site-packages
  WSGIScriptAlias / "/var/www/toaster/poky/bitbake/lib/toaster/toastermain/wsgi.py"
  WSGIScriptAlias / "/var/www/toaster/poky/bitbake/lib/toaster/toastermain/wsgi.py"
  <Location />
  <Location />
     WSGIProcessGroup toastern_wsgi
     WSGIProcessGroup toastern_wsgi
  </Location>
  </Location>
</code>


</code>
</code>
Line 90: Line 112:




#
'''7 restart Apache web server'''
 
Ubuntu/Debian:
<code>
  $ sudo service apache2 restart
</code>
 
Fedora/RH:
<code>
  $ sudo service httpd restart
</code>

Revision as of 15:20, 16 October 2015


A production instance of Toaster is one in which you wish to share the Toaster instance with remote and multiple users. It is also the setup which can cope with heavier loads on the web service. These instructions setup toaster in Build mode where builds and projects are run, viewed and defined by the Toaster web interface.

Requirements

Ubuntu 14.04.3:

   $ sudo apt-get install apache2 libapache2-mod-wsgi mysql-server virtualenv libmysqlclient-dev

Fedora 22/RH:

   $ sudo dnf install httpd mod_wsgi python-virtualenv gcc mysql-devel


Installation

1. Checkout a copy of Poky into the web server directory. We're going to be using /var/www/toaster.

 $ mkdir -p /var/www/toaster
 $ cd /var/www/toaster/
 $ git clone git://git.yoctoproject.org/poky
 $ git checkout jethro # change for any release name required

2. Initialise a virtualenv and install Toaster dependencies. (Use virtualenv to keep the python packages isolated from your system provided packages - not required but recommended, alternative use your OS's package manager to install the packages)

  $ cd /var/www/toaster/
  $ virtualenv venv
  $ source ./venv/bin/activate
  $ pip install -r ./poky/bitbake/toaster-requirements.txt
  $ pip install mysql
  $ pip install MySQL-python

3. Configure toaster edit /var/www/toaster/poky/bitbake/lib/toaster/toastermain/settings.py

Edit the DATABASE settings:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', 
        'NAME': 'toaster_data',                     
        'USER': 'toaster',
        'PASSWORD': 'yourpasswordhere',
        'HOST': 'localhost',                 
        'PORT': '3306',                      
}

Edit the SECRET_KEY:

SECRET_KEY = 'YOUR SECRET RANDOM KEY HERE'

Edit the STATIC_ROOT:

STATIC_ROOT = '/var/www/toaster/static_files/'

4. Now add the database and user to your mysql server that we just defined

$ mysql -u root -p
mysql> CREATE DATABASE toaster;
mysql> CREATE USER 'toaster'@'localhost' identified by 'yourpasswordhere';
mysql> GRANT all on toaster_data.* to 'toaster'@'localhost';
mysql> quit

n.b. You may want to decide on fewer privileges to the toaster user.

5. Get toaster to create the database schema and default data

$ cd  /var/www/toaster/poky/
$ ./bitbake/lib/toaster/manage.py syncdb --migrate
$ ./bitbake/lib/toaster/manage.py loadconf ./meta-yocto/conf/toasterconf.json
$ ./bitbake/lib/toaster/manage.py lsupdates


6. Add a config file for Toaster to your Apache webserver configurations available directory.

Ubuntu/Debian put it here: /etc/apache2/conf-available/toaster.conf Fedora/RH : /etc/httpd/conf.d/toaster.conf

Alias /static /var/www/toaster/static_files
<Directory /var/www/toaster/static_files>
	Order allow,deny
	Allow from all
	Require all granted
</Directory>
WSGIDaemonProcess toaster_wsgi python-path=/var/www/toaster/toaster-next/bitbake/lib/toaster:/var/www/toaster /venv/lib/python2.7/site-packages
WSGIScriptAlias / "/var/www/toaster/poky/bitbake/lib/toaster/toastermain/wsgi.py"
<Location />
    WSGIProcessGroup toastern_wsgi
</Location>

In Ubuntu/Debain you will need to enable the config in Apache webserver

  $ sudo a2enmod wsgi toaster 


7 restart Apache web server

Ubuntu/Debian:

  $ sudo service apache2 restart

Fedora/RH:

  $ sudo service httpd restart