Bug fixes and fine-tuning to make local development more awesome.
This commit is contained in:
parent
39fe443ccd
commit
8cc1f77fe9
|
@ -57,6 +57,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|||
# View the documentation for the provider you're using for more
|
||||
# information on available options.
|
||||
|
||||
config.vm.provider :virtualbox do |vb|
|
||||
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
|
||||
vb.customize ["modifyvm", :id, "--memory", "1024"]
|
||||
end
|
||||
|
||||
# Enable provisioning with CFEngine. CFEngine Community packages are
|
||||
# automatically installed. For example, configure the host as a
|
||||
# policy server and optionally a policy file to run:
|
||||
|
|
|
@ -46,7 +46,7 @@ else
|
|||
define("DF_URL_STATIC", '/static');
|
||||
|
||||
// Set error reporting for the bootstrapping process.
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
|
||||
|
||||
// Set include path (as needed by CLI access.)
|
||||
$include_path = array(DF_INCLUDE_LIB, DF_INCLUDE_VENDOR, get_include_path());
|
||||
|
|
|
@ -22,18 +22,19 @@ class AnalyticsManager
|
|||
$hour_interval = 3600;
|
||||
|
||||
// Get the earliest date that statistics are available for.
|
||||
$earliest_date_raw = $em->createQuery('SELECT s.timestamp FROM Entity\Statistic s ORDER BY s.id ASC')
|
||||
->setMaxResults(1)
|
||||
->getSingleScalarResult();
|
||||
|
||||
if (!$earliest_date_raw)
|
||||
return;
|
||||
try
|
||||
{
|
||||
$earliest_date_raw = $em->createQuery('SELECT s.timestamp FROM Entity\Statistic s ORDER BY s.id ASC')
|
||||
->setMaxResults(1)
|
||||
->getSingleScalarResult();
|
||||
}
|
||||
catch(\Exception $e) { return false; }
|
||||
|
||||
$earliest_timestamp = strtotime($earliest_date_raw);
|
||||
$earliest_date = date('Y-m-d', $earliest_timestamp);
|
||||
|
||||
if ($earliest_date == $current_date)
|
||||
return;
|
||||
return false;
|
||||
|
||||
// Loop through all days.
|
||||
$start_timestamp = strtotime($earliest_date.' 00:00:00');
|
||||
|
|
|
@ -86,6 +86,10 @@ class NotificationManager
|
|||
{
|
||||
static $twitter;
|
||||
|
||||
// Suppress notifications for non-production applications.
|
||||
if (DF_APPLICATION_ENV != "production")
|
||||
return false;
|
||||
|
||||
if (!$twitter)
|
||||
{
|
||||
// The @PVLiveShows Twitter Account
|
||||
|
|
|
@ -76,7 +76,7 @@ class AdapterAbstract
|
|||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2');
|
||||
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2');
|
||||
|
||||
$return_raw = \PVL\Utilities::curl_exec_utf8($curl);
|
||||
// End cURL request.
|
||||
|
|
|
@ -31,6 +31,7 @@ class Api_DevController extends \PVL\Controller\Action\Api
|
|||
$tables = array(
|
||||
'settings',
|
||||
'block',
|
||||
'affiliates',
|
||||
'action',
|
||||
'role',
|
||||
'role_has_action',
|
||||
|
@ -76,4 +77,33 @@ class Api_DevController extends \PVL\Controller\Action\Api
|
|||
@unlink($destination_path);
|
||||
}
|
||||
}
|
||||
|
||||
public function staticAction()
|
||||
{
|
||||
$directories = array(
|
||||
'affiliates',
|
||||
'artists',
|
||||
'podcasts',
|
||||
'rotators',
|
||||
'songs',
|
||||
'stations',
|
||||
);
|
||||
|
||||
$static_files = array();
|
||||
|
||||
foreach($directories as $dir)
|
||||
{
|
||||
$dir_path = DF_INCLUDE_STATIC.DIRECTORY_SEPARATOR.$dir;
|
||||
$files_raw = @scandir($dir_path);
|
||||
|
||||
foreach($files_raw as $file)
|
||||
{
|
||||
$path = $dir_path.DIRECTORY_SEPARATOR.$file;
|
||||
if (!is_dir($path))
|
||||
$static_files[$dir][$file] = \DF\Url::content($dir.'/'.$file);
|
||||
}
|
||||
}
|
||||
|
||||
$this->returnSuccess($static_files);
|
||||
}
|
||||
}
|
|
@ -6,9 +6,10 @@
|
|||
require_once dirname(__FILE__) . '/../app/bootstrap.php';
|
||||
$application->bootstrap();
|
||||
|
||||
if (DF_APPLICATION_ENV != 'production')
|
||||
\PVL\Debug::setEchoMode(TRUE);
|
||||
|
||||
set_time_limit(60);
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('memory_limit', '256M');
|
||||
|
||||
// Prevent nowplaying from running on top of itself.
|
||||
|
|
|
@ -7,8 +7,6 @@ require_once dirname(__FILE__) . '/../app/bootstrap.php';
|
|||
$application->bootstrap();
|
||||
|
||||
set_time_limit(300);
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('memory_limit', '256M');
|
||||
|
||||
// Generate cache files.
|
||||
|
|
|
@ -7,8 +7,6 @@ require_once dirname(__FILE__) . '/../app/bootstrap.php';
|
|||
$application->bootstrap();
|
||||
|
||||
set_time_limit(60);
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('memory_limit', '256M');
|
||||
|
||||
// Pull the homepage news.
|
||||
|
|
|
@ -7,8 +7,6 @@ require_once dirname(__FILE__) . '/../app/bootstrap.php';
|
|||
$application->bootstrap();
|
||||
|
||||
set_time_limit(1800);
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('memory_limit', '256M');
|
||||
|
||||
// Sync analytical and statistical data (long running).
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
20 * * * * sudo -u www-data php /var/www/vagrant/util/syncslow.php
|
||||
*/15 * * * * sudo -u www-data php /var/www/vagrant/util/sync.php
|
||||
* * * * * sudo -u www-data php /var/www/vagrant/util/syncfast.php
|
||||
* * * * * sudo -u www-data php /var/www/vagrant/util/nowplaying.php
|
||||
* * * * * sleep 15; sudo -u www-data php /var/www/vagrant/util/nowplaying.php
|
||||
* * * * * sleep 30; sudo -u www-data php /var/www/vagrant/util/nowplaying.php
|
||||
* * * * * sleep 45; sudo -u www-data php /var/www/vagrant/util/nowplaying.php
|
||||
20 * * * * php /var/www/vagrant/util/syncslow.php
|
||||
*/15 * * * * php /var/www/vagrant/util/sync.php
|
||||
* * * * * php /var/www/vagrant/util/syncfast.php
|
||||
* * * * * php /var/www/vagrant/util/nowplaying.php
|
||||
* * * * * sleep 30; php /var/www/vagrant/util/nowplaying.php
|
||||
|
|
|
@ -1,40 +1,52 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ -f /var/www/.deploy_run ]
|
||||
export app_base=/var/www
|
||||
export tmp_base=$app_base/www_tmp
|
||||
export www_base=$app_base/vagrant
|
||||
|
||||
if [ -f $app_base/.deploy_run ]
|
||||
then
|
||||
echo 'One-time setup has already been done!'
|
||||
exit
|
||||
fi
|
||||
|
||||
# Set up environment.
|
||||
touch /var/www/.deploy_run
|
||||
touch /var/www/vagrant/app/.updated
|
||||
touch $app_base/.deploy_run
|
||||
touch $www_base/app/.updated
|
||||
|
||||
echo 'development' > /var/www/vagrant/app/.env
|
||||
echo 'development' > $app_base/app/.env
|
||||
|
||||
# Goodies for nerds. ;)
|
||||
apt-get -q -y install vim
|
||||
apt-get -q -y remove redis-server
|
||||
apt-get -q -y remove mongodb-org
|
||||
apt-get autoremove
|
||||
|
||||
# Create temp folders.
|
||||
mkdir -p /var/www/www_tmp
|
||||
mkdir -p /var/www/www_tmp/cache
|
||||
mkdir -p /var/www/www_tmp/sessions
|
||||
mkdir -p /var/www/www_tmp/proxies
|
||||
echo "Creating temporary folders..."
|
||||
mkdir -p $tmp_base
|
||||
mkdir -p $tmp_base/cache
|
||||
mkdir -p $tmp_base/sessions
|
||||
mkdir -p $tmp_base/proxies
|
||||
|
||||
# Create log files.
|
||||
touch /var/www/www_tmp/access.log
|
||||
touch /var/www/www_tmp/error.log
|
||||
touch /var/www/www_tmp/php_errors.log
|
||||
echo "Setting permissions..."
|
||||
touch $tmp_base/access.log
|
||||
touch $tmp_base/error.log
|
||||
touch $tmp_base/php_errors.log
|
||||
touch $tmp_base/vagrant_import.sql
|
||||
|
||||
usermod -G vagrant www-data
|
||||
usermod -G vagrant nobody
|
||||
|
||||
chown -R vagrant:vagrant /var/www/www_tmp/
|
||||
chown -R vagrant:vagrant $tmp_base/
|
||||
|
||||
chmod -R 777 /var/www/www_tmp
|
||||
# chmod -R 775 /var/www/vagrant/web/static
|
||||
chmod -R 777 $tmp_base
|
||||
# chmod -R 775 $www_base/web/static
|
||||
|
||||
# Service setup.
|
||||
echo "Customizing nginx..."
|
||||
|
||||
service nginx stop
|
||||
|
||||
mv /etc/nginx/conf/nginx.conf /etc/nginx/conf/nginx.conf.bak
|
||||
|
@ -43,23 +55,27 @@ cp /vagrant/util/vagrant_nginx /etc/nginx/conf/nginx.conf
|
|||
service nginx start
|
||||
|
||||
# Set up MySQL server.
|
||||
cat /var/www/vagrant/util/vagrant_mycnf >> /etc/mysql/my.cnf
|
||||
echo "Customizing MySQL..."
|
||||
|
||||
cat $www_base/util/vagrant_mycnf >> /etc/mysql/my.cnf
|
||||
|
||||
echo 'CREATE DATABASE pvl CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' | mysql -u root -ppassword
|
||||
service mysql restart
|
||||
|
||||
# Copy sample files.
|
||||
if [ ! -f /var/www/vagrant/app/config/apis.conf.php ]
|
||||
if [ ! -f $www_base/app/config/apis.conf.php ]
|
||||
then
|
||||
cp /var/www/vagrant/app/config/apis.conf.sample.php /var/www/vagrant/app/config/apis.conf.php
|
||||
cp $www_base/app/config/apis.conf.sample.php $www_base/app/config/apis.conf.php
|
||||
fi
|
||||
|
||||
if [ ! -f /var/www/vagrant/app/config/db.conf.php ]
|
||||
if [ ! -f $www_base/app/config/db.conf.php ]
|
||||
then
|
||||
cp /var/www/vagrant/app/config/db.conf.sample.php /var/www/vagrant/app/config/db.conf.php
|
||||
cp $www_base/app/config/db.conf.sample.php $www_base/app/config/db.conf.php
|
||||
fi
|
||||
|
||||
# Install PHP-CLI
|
||||
echo "Installing PHP5 Command Line Interface (CLI)..."
|
||||
|
||||
apt-get -q -y install php5-cli
|
||||
|
||||
echo "alias phpwww='sudo -u www-data php'" >> /home/vagrant/.profile
|
||||
|
@ -74,21 +90,38 @@ sed -e '/^[^;]*short_open_tag/s/=.*$/= On/' -i.bak /etc/php5/cli/php.ini
|
|||
service php5-fpm restart
|
||||
|
||||
# Install composer.
|
||||
echo "Installing Composer..."
|
||||
cd /root
|
||||
curl -sS https://getcomposer.org/installer | php
|
||||
mv composer.phar /usr/local/bin/composer
|
||||
|
||||
if [ ! -f /var/www/vagrant/vendor/autoload.php ]
|
||||
if [ ! -f $www_base/vendor/autoload.php ]
|
||||
then
|
||||
cd /var/www/vagrant
|
||||
cd $www_base
|
||||
composer install
|
||||
fi
|
||||
|
||||
# Set up DB.
|
||||
cd /var/www/vagrant/util
|
||||
echo "Setting up database..."
|
||||
|
||||
cd $www_base/util
|
||||
sudo -u www-data php doctrine.php orm:schema-tool:create
|
||||
sudo -u www-data php flush.php
|
||||
sudo -u www-data php vagrant_import.php
|
||||
|
||||
echo "Importing external music databases (takes a minute)..."
|
||||
sudo -u www-data php syncslow.php
|
||||
|
||||
echo "Running regular tasks..."
|
||||
sudo -u www-data php syncfast.php
|
||||
sudo -u www-data php sync.php
|
||||
|
||||
sudo -u www-data php nowplaying.php
|
||||
|
||||
# Add cron job
|
||||
crontab /var/www/vagrant/util/vagrant_cron
|
||||
echo "Installing cron job..."
|
||||
crontab -u vagrant $www_base/util/vagrant_cron
|
||||
service cron restart
|
||||
|
||||
echo "One-time setup complete!"
|
||||
echo "Server now live at localhost:8080 or www.pvlive.dev:8080."
|
|
@ -10,13 +10,18 @@ set_time_limit(0);
|
|||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
|
||||
$api_key = $config->apis->pvl_api_key;
|
||||
$remote_base = 'http://ponyvillelive.com';
|
||||
|
||||
if (empty($api_key))
|
||||
die('No API key specified in app/config/apis.conf.php. Please contact PVL developer team!');
|
||||
|
||||
$remote_base = 'http://ponyvillelive.com';
|
||||
$remote_url = $remote_base.'/api/dev/import?key='.$api_key;
|
||||
/**
|
||||
* Database Import
|
||||
*/
|
||||
|
||||
echo 'Importing database entries from production server...'.PHP_EOL;
|
||||
|
||||
$remote_url = $remote_base.'/api/dev/import?key='.$api_key;
|
||||
$local_temp = DF_INCLUDE_TEMP.DIRECTORY_SEPARATOR.'vagrant_import.sql';
|
||||
|
||||
// Pull from remote API.
|
||||
|
@ -60,11 +65,51 @@ $command_flags = array(
|
|||
);
|
||||
$command = 'mysql '.implode(' ', $command_flags).' < '.$local_temp;
|
||||
|
||||
echo $command;
|
||||
|
||||
passthru($command);
|
||||
|
||||
// @unlink($local_temp);
|
||||
@unlink($local_temp);
|
||||
|
||||
echo 'Database import complete.'.PHP_EOL;
|
||||
|
||||
/**
|
||||
* Static Asset Import
|
||||
*/
|
||||
|
||||
echo 'Pulling static assets...'.PHP_EOL;
|
||||
|
||||
$remote_url = $remote_base.'/api/dev/static?key='.$api_key;
|
||||
|
||||
$static_raw = file_get_contents($remote_url);
|
||||
$static_result = @json_decode($static_raw, TRUE);
|
||||
|
||||
if (isset($static_result['result']))
|
||||
{
|
||||
$static_folders = $static_result['result'];
|
||||
$ch = curl_init();
|
||||
|
||||
foreach($static_folders as $dir_name => $dir_files)
|
||||
{
|
||||
$local_dir = DF_INCLUDE_STATIC.DIRECTORY_SEPARATOR.$dir_name;
|
||||
@mkdir($local_dir);
|
||||
|
||||
foreach($dir_files as $file_base => $remote_url)
|
||||
{
|
||||
$local_file = $local_dir.DIRECTORY_SEPARATOR.$file_base;
|
||||
|
||||
$fp = fopen($local_file, 'w');
|
||||
$options = array(
|
||||
CURLOPT_FILE => $fp,
|
||||
CURLOPT_TIMEOUT => 28800,
|
||||
CURLOPT_URL => $remote_url,
|
||||
);
|
||||
curl_setopt_array($ch, $options);
|
||||
curl_exec($ch);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
echo ' - Finished importing "'.$dir_name.'".'.PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
echo 'Static assets complete.'.PHP_EOL;
|
||||
exit;
|
|
@ -171,7 +171,7 @@ function checkNowPlaying(force_update)
|
|||
|
||||
jQuery.ajax({
|
||||
cache: false,
|
||||
url: '//ponyvillelive.com/static/api/nowplaying.json',
|
||||
url: DF_ContentPath+'/api/nowplaying.json',
|
||||
dataType: 'json'
|
||||
}).done(function(data) {
|
||||
var listener_total = 0;
|
||||
|
|
Loading…
Reference in New Issue