Skip to content

Commit

Permalink
merge upstream changes, new api feature /api/status
Browse files Browse the repository at this point in the history
  • Loading branch information
kristofkeppens committed Mar 18, 2015
2 parents d53484d + 9f44bd0 commit a6bea7a
Show file tree
Hide file tree
Showing 17 changed files with 162 additions and 60 deletions.
53 changes: 33 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,21 @@ You can use a chef recipe to setup your server or setup a vagrant box.

Dependencies

sudo apt-get install php5-common
sudo apt-get install php5
sudo apt-get install php5-xcache
sudo apt-get install php5-mongo
sudo apt-get install php5-fpm
sudo apt-get install php5-curl
sudo apt-get install mongodb
sudo apt-get install npm

Get the code

git clone [email protected]:brunogoossens/BBB-Load-Balancer.git /var/www/bbb-load-balancer
cd /var/www/bbb-load-balancer
php5-common
php5-cli
php5-xcache
php5-mongo
php5-curl
mongodb
npm
node
git
curl

Get the code (change the destination)

$ git clone https://github.com/brunogoossens/BBB-Load-Balancer.git /path/of/project
$ cd /path/of/project

Get NPM packages

Expand All @@ -56,7 +58,7 @@ Edit the config file

$ cp app/config/parameters.yml.dist app/config/parameters.yml

Change the bbb.salt value inside the file. The salt must be the same on all BBB servers
Change the bbb.salt value inside the new file. The salt must be the same on all BBB servers
You can also change other values if you like.

Get composer
Expand All @@ -65,26 +67,37 @@ Get composer

Install packages with composer

composer install
$ ./composer.phar install

Start server (without apache or nginx)

$ app/console server:run --env=prod

If you want to configure an other server like apache or nginx, you can follow [this](http://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html) guide.
Make sure if you use a webserver, that it has write access to the app/cache and app/log folders. You can read more about this [here](http://symfony.com/doc/current/book/installation.html). Search the page for "Setting up Permissions".

To automatically enable and disable servers based on there status, you can add this cronjob.

* * * * * /path/to/project/app/console bbblb:servers:check --env=prod
* * * * * /path/of/project/app/console bbblb:servers:check --env=prod

To remove stopped meetings from the load balancer.
To remove stopped meetings from the load balancer, add this cronjob.

* * * * * /path/to/project/app/console bbblb:meetings:cleanup --env=prod
* * * * * /path/of/project/app/console bbblb:meetings:cleanup --env=prod

# Adding BBB Servers to the load balancer #

Access the web interface: http://127.0.0.1:8000 (or vhost configured in apache or nginx)
The first time you access this page, you must create an admin user. After creating this user, you can manage the BBB load balancer. You need to add at least 1 BBB server to the list of servers before you can use the load balancer.
The first time you access this page, you must create an admin user. After creating this user, you can manage the BBB load balancer. You need to add at least 1 BBB server to the list of servers before you can use the load balancer. After setting up the load balancer, you should change your client applications BBB url to the new BBB load balancer URL.
(http://127.0.0.1/bigbluebutton)

# Updating the loadbalancer #

So we added cool new features to the repository but you have deployed old code. You should do the following commands to get the newest code.

$ cd /path/of/project/bbb-load-balancer
$ git pull
$ app/console cache:clear --env=prod
$ app/console assets:install
$ app/console assetic:dump --env=prod

# Contact #

Expand Down
1 change: 1 addition & 0 deletions app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function registerBundles()
new BBBLoadBalancer\AdminBundle\BBBLoadBalancerAdminBundle(),
new BBBLoadBalancer\ThemeBundle\BBBLoadBalancerThemeBundle(),
new BBBLoadBalancer\UserBundle\BBBLoadBalancerUserBundle(),
new BBBLoadBalancer\BBBBundle\BBBLoadBalancerBBBBundle(),
);

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
Expand Down
2 changes: 1 addition & 1 deletion app/Resources/TwigBundle/views/Exception/error.json.twig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{{ { 'message': exception.message }|json_encode|raw }}]
[{{ { 'status_text': status_text, 'message': exception.message }|json_encode|raw }}]
1 change: 1 addition & 0 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ twig:

# Assetic Configuration
assetic:
node: "%sys.path_node%"
debug: "%kernel.debug%"
use_controller: false
bundles: [ "BBBLoadBalancerThemeBundle", "BBBLoadBalancerAdminBundle" ]
Expand Down
2 changes: 2 additions & 0 deletions app/config/parameters.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ parameters:
debug_redirects: false
use_assetic_controller: true

sys.path_node: node

app.site_name: BBB Load Balancer
app.domain: domainname.com
app.email_name: BBB Load Balancer
Expand Down
5 changes: 5 additions & 0 deletions app/config/routing.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
bbb_load_balancer_bbb:
resource: "@BBBLoadBalancerBBBBundle/Controller/"
type: annotation
prefix: /

bbb_load_balancer_theme:
resource: "@BBBLoadBalancerThemeBundle/Controller/"
type: annotation
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace BBBLoadBalancer\AdminBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
use BBBLoadBalancer\UserBundle\Annotations\ValidAPIKey;

class DefaultAPIController extends Controller
{
/**
* @Route("/api/status", name="status", defaults={"_format": "json"})
* @Method({"GET"})
* @ValidAPIKey
*/
public function statusAction(Request $request)
{
$return = array(
'servers' => array()
);

// return all servers
$servers = $this->get('server')->getServersBy(array("enabled" => true, "up" => true));
if(empty($servers)){
return new JsonResponse(array(
"status" => "ERROR",
"message" => "No Servers found that are enabled and up."
)
);
}

$servercount = count($servers);

return new JsonResponse(array(
"status" => "OK",
"message" => "$servercount servers are used by the load balancer."
)
);
}
}
3 changes: 0 additions & 3 deletions src/BBBLoadBalancer/AdminBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ services:
meeting:
class: BBBLoadBalancer\AdminBundle\Service\MeetingService
arguments: [ @doctrine_mongodb, @validator ]
bbb:
class: BBBLoadBalancer\AdminBundle\Service\BBBService
arguments: [ %bbb.salt%, @logger ]
server:
class: BBBLoadBalancer\AdminBundle\Service\ServerService
arguments: [ @doctrine_mongodb, @bbb, @validator, @meeting, @logger ]
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ <h3>BigBlueButton API</h3>
<h3>BBB Load Balancer API</h3>
<p>The API can be used on the endpoint "/api" and can only be used with the JSON format. To get access, you need to add the API key to the header of the request with the name "API-key". <br/>Example header: API-key:CTCTn8rMMvjj2AGoQkUBC5iEpfbvplb1eOVCWmoJRH2ThIi83c. Each user has his own API key.</p>
<br/>
<h4>Status</h4>
<p><kbd>/api/status (GET)</kbd></p>
<br/>
<h4>List servers</h4>
<p><kbd>/api/servers (GET)</kbd></p>
<br/>
Expand Down

This file was deleted.

9 changes: 9 additions & 0 deletions src/BBBLoadBalancer/BBBBundle/BBBLoadBalancerBBBBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace BBBLoadBalancer\BBBBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class BBBLoadBalancerBBBBundle extends Bundle
{
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace BBBLoadBalancer\AdminBundle\Controller;
namespace BBBLoadBalancer\BBBBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace BBBLoadBalancer\BBBBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;

/**
* This is the class that loads and manages your bundle configuration
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/
class BBBLoadBalancerBBBExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace BBBLoadBalancer\BBBBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
* This is the class that validates and merges configuration from your app/config files
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('bbb_load_balancer_bbb');

// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
// more information on that topic.

return $treeBuilder;
}
}
4 changes: 4 additions & 0 deletions src/BBBLoadBalancer/BBBBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
bbb:
class: BBBLoadBalancer\BBBBundle\Service\BBBService
arguments: [ %bbb.salt%, @logger ]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace BBBLoadBalancer\AdminBundle\Service;
namespace BBBLoadBalancer\BBBBundle\Service;

class BBBService
{
Expand Down

This file was deleted.

0 comments on commit a6bea7a

Please sign in to comment.