Setting up a production instance of Toaster: Difference between revisions

From Yocto Project
Jump to navigationJump to search
No edit summary
No edit summary
 
(23 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:Toaster]]
[[Category:Toaster]]
 
----
{| style="color:black; background-color:#ffffcc" width="100%" cellpadding="10" class="wikitable"
|This page is the development version of the documentation to provide the latest information, if you're using a release please refer to [https://docs.yoctoproject.org/toaster-manual/index.html the published manual]'''
|}
----
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.
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.


Line 11: Line 15:
Ubuntu 14.04.3:
Ubuntu 14.04.3:
<code>
<code>
     $ sudo apt-get install apache2 libapache2-mod-wsgi mysql-server virtualenv libmysqlclient-dev
     $ sudo apt-get install apache2 libapache2-mod-wsgi mysql-server python-virtualenv libmysqlclient-dev python-dev python-mysqldb
</code>
</code>


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


== Installation ==
== Installation ==


'''1. 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
   $ cd /var/www/toaster/
   $ cd /var/www/toaster/
   $ git clone git://git.yoctoproject.org/poky
   $ git clone git://git.yoctoproject.org/poky
  $ cd poky
   $ git checkout jethro # change for any release name required
   $ git checkout jethro # change for any release name required
</code>
</code>


'''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)'''
 
'''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 37: Line 42:
   $ source ./venv/bin/activate
   $ source ./venv/bin/activate
   $ pip install -r ./poky/bitbake/toaster-requirements.txt
   $ pip install -r ./poky/bitbake/toaster-requirements.txt
   $ pip install mysql
   $ pip install mysqlclient
  $ pip install MySQL-python
</code>
</code>


'''3. 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:
Edit the DATABASE settings:
Line 56: Line 61:
</code>
</code>


Edit the SECRET_KEY:
Edit the [https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/#secret-key SECRET_KEY]:
<code>
<code>
  SECRET_KEY = 'YOUR SECRET RANDOM KEY HERE'
  SECRET_KEY = 'YOUR SECRET RANDOM KEY HERE'
Line 66: Line 71:
</code>
</code>


'''4. Now add the database and user to your mysql server that we just defined'''
 
'''4.'''' Now add the database and user to your mysql server that we just defined
<code>
<code>
  $ mysql -u root -p
  $ mysql -u root -p
  mysql> CREATE DATABASE toaster;
  mysql> CREATE DATABASE toaster_data;
  mysql> CREATE USER 'toaster'@'localhost' identified by 'yourpasswordhere';
  mysql> CREATE USER 'toaster'@'localhost' identified by 'yourpasswordhere';
  mysql> GRANT all on toaster_data.* to 'toaster'@'localhost';
  mysql> GRANT all on toaster_data.* to 'toaster'@'localhost';
Line 76: Line 82:
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.  
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'''
 
'''5.''' Get toaster to create the database schema, default data, update the TOASTER_DIR which is the build work dir and collect up the statically served files


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




'''6. Add a config file for Toaster to your Apache webserver configurations available directory. '''
'''6.''' Add a config file for Toaster to your Apache web server's 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
Fedora/RH : /etc/httpd/conf.d/toaster.conf
Fedora/RH usually here: /etc/httpd/conf.d/toaster.conf
<code>
<code>


Line 98: Line 107:
  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/poky/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 toaster_wsgi
  </Location>
  </Location>


</code>
</code>


In Ubuntu/Debain you will need to enable the config in Apache webserver
In Ubuntu/Debain you will need to enable the config and module in Apache webserver
<code>
<code>
   $ sudo a2enmod wsgi toaster  
   $ sudo a2enmod wsgi
  $ sudo a2enconf toaster
</code>
</code>


 
Restart Apache web server to make sure all new configuration is loaded
'''7 restart Apache web server'''


Ubuntu/Debian:
Ubuntu/Debian:
Line 123: Line 132:
   $ sudo service httpd restart
   $ sudo service httpd restart
</code>
</code>
'''7.''' Install the build runner service
This service needs to be running in order to dispatch builds the command that needs to be run is:
<code>
$ source oe-init-build-env
$ source toaster start noweb
</code>
Example upstart service /etc/init/toaster-buildservice.conf :
<pre>
author "Michael W"
description "start and stop toaster build service"
version "1.0"
start on started networking
stop on runlevel [!2345]
respawn
script
  exec su toasterbuilder -c "cd /var/www/toaster/poky && source oe-init-build-env && source toaster start noweb"
end script
</pre>
Example systemd service usually in /lib/systemd/system/toaster.service:
<pre>
[Unit]
Description=Toaster runbuilds
[Service]
Type=forking
User=toaster
ExecStart=/var/www/toaster/toaster-service.sh start
ExecStop=/var/www/toaster/toaster-service.sh stop
[Install]
WantedBy=multi-user.target
</pre>
script /var/www/toaster/toaster-service.sh:
<pre>
#!/bin/bash
cd /var/www/toaster/poky/
source oe-init-build-env
if [ "$1" == 'start' ]; then
  source ../bitbake/bin/toaster start noweb
fi
if [ "$1" == 'stop' ]; then
  source ../bitbake/bin/toaster stop
fi
</pre>
N.b. You may wish to add a service entry to your OS's init system so that it starts up on start up as well as adding a dedicated user.
Now open up a browser and you can start using Toaster!

Latest revision as of 00:42, 18 February 2024


This page is the development version of the documentation to provide the latest information, if you're using a release please refer to the published manual

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 python-virtualenv libmysqlclient-dev python-dev python-mysqldb

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
 $ cd 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 mysqlclient


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_data;
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, default data, update the TOASTER_DIR which is the build work dir and collect up the statically served files

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


6. Add a config file for Toaster to your Apache web server's configurations available directory.

Ubuntu/Debian put it here: /etc/apache2/conf-available/toaster.conf Fedora/RH usually here: /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/poky/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 toaster_wsgi
</Location>

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

  $ sudo a2enmod wsgi
  $ sudo a2enconf toaster

Restart Apache web server to make sure all new configuration is loaded

Ubuntu/Debian:

  $ sudo service apache2 restart

Fedora/RH:

  $ sudo service httpd restart


7. Install the build runner service

This service needs to be running in order to dispatch builds the command that needs to be run is:

$ source oe-init-build-env
$ source toaster start noweb


Example upstart service /etc/init/toaster-buildservice.conf :

 author "Michael W"
 description "start and stop toaster build service"
 version "1.0"

 start on started networking
 stop on runlevel [!2345]

 respawn

 script
   exec su toasterbuilder -c "cd /var/www/toaster/poky && source oe-init-build-env && source toaster start noweb"
 end script


Example systemd service usually in /lib/systemd/system/toaster.service:

 
[Unit]
Description=Toaster runbuilds
 
[Service]
Type=forking
User=toaster
ExecStart=/var/www/toaster/toaster-service.sh start
ExecStop=/var/www/toaster/toaster-service.sh stop
 
[Install]
WantedBy=multi-user.target

script /var/www/toaster/toaster-service.sh:


#!/bin/bash
 
cd /var/www/toaster/poky/
 
source oe-init-build-env
if [ "$1" == 'start' ]; then
  source ../bitbake/bin/toaster start noweb
fi
 
if [ "$1" == 'stop' ]; then
  source ../bitbake/bin/toaster stop
fi


N.b. You may wish to add a service entry to your OS's init system so that it starts up on start up as well as adding a dedicated user.


Now open up a browser and you can start using Toaster!