Skip to content
This repository was archived by the owner on Nov 27, 2018. It is now read-only.

Commit 1f6301a

Browse files
committed
changes
1 parent b41fc5b commit 1f6301a

File tree

7 files changed

+1217
-1
lines changed

7 files changed

+1217
-1
lines changed

bin/console

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use Symfony\Bundle\FrameworkBundle\Console\Application;
5+
use Symfony\Component\Console\Input\ArgvInput;
6+
use Symfony\Component\Debug\Debug;
7+
8+
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
9+
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
10+
//umask(0000);
11+
12+
set_time_limit(0);
13+
14+
/**
15+
* @var Composer\Autoload\ClassLoader $loader
16+
*/
17+
$loader = require __DIR__.'/../app/autoload.php';
18+
19+
$input = new ArgvInput();
20+
$env = $input->getParameterOption(['--env', '-e'], getenv('APP_ENV') ?: 'dev');
21+
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod';
22+
23+
if ($debug) {
24+
Debug::enable();
25+
}
26+
27+
$kernel = new AppKernel($env, $debug);
28+
$application = new Application($kernel);
29+
$application->run($input);

bin/symfony_requirements

+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
require_once dirname(__FILE__).'/../var/SymfonyRequirements.php';
5+
6+
$lineSize = 70;
7+
$symfonyRequirements = new SymfonyRequirements();
8+
$iniPath = $symfonyRequirements->getPhpIniConfigPath();
9+
10+
echo_title('Symfony Requirements Checker');
11+
12+
echo '> PHP is using the following php.ini file:'.PHP_EOL;
13+
if ($iniPath) {
14+
echo_style('green', ' '.$iniPath);
15+
} else {
16+
echo_style('yellow', ' WARNING: No configuration file (php.ini) used by PHP!');
17+
}
18+
19+
echo PHP_EOL.PHP_EOL;
20+
21+
echo '> Checking Symfony requirements:'.PHP_EOL.' ';
22+
23+
$messages = array();
24+
foreach ($symfonyRequirements->getRequirements() as $req) {
25+
if ($helpText = get_error_message($req, $lineSize)) {
26+
echo_style('red', 'E');
27+
$messages['error'][] = $helpText;
28+
} else {
29+
echo_style('green', '.');
30+
}
31+
}
32+
33+
$checkPassed = empty($messages['error']);
34+
35+
foreach ($symfonyRequirements->getRecommendations() as $req) {
36+
if ($helpText = get_error_message($req, $lineSize)) {
37+
echo_style('yellow', 'W');
38+
$messages['warning'][] = $helpText;
39+
} else {
40+
echo_style('green', '.');
41+
}
42+
}
43+
44+
if ($checkPassed) {
45+
echo_block('success', 'OK', 'Your system is ready to run Symfony projects');
46+
} else {
47+
echo_block('error', 'ERROR', 'Your system is not ready to run Symfony projects');
48+
49+
echo_title('Fix the following mandatory requirements', 'red');
50+
51+
foreach ($messages['error'] as $helpText) {
52+
echo ' * '.$helpText.PHP_EOL;
53+
}
54+
}
55+
56+
if (!empty($messages['warning'])) {
57+
echo_title('Optional recommendations to improve your setup', 'yellow');
58+
59+
foreach ($messages['warning'] as $helpText) {
60+
echo ' * '.$helpText.PHP_EOL;
61+
}
62+
}
63+
64+
echo PHP_EOL;
65+
echo_style('title', 'Note');
66+
echo ' The command console could use a different php.ini file'.PHP_EOL;
67+
echo_style('title', '~~~~');
68+
echo ' than the one used with your web server. To be on the'.PHP_EOL;
69+
echo ' safe side, please check the requirements from your web'.PHP_EOL;
70+
echo ' server using the ';
71+
echo_style('yellow', 'web/config.php');
72+
echo ' script.'.PHP_EOL;
73+
echo PHP_EOL;
74+
75+
exit($checkPassed ? 0 : 1);
76+
77+
function get_error_message(Requirement $requirement, $lineSize)
78+
{
79+
if ($requirement->isFulfilled()) {
80+
return;
81+
}
82+
83+
$errorMessage = wordwrap($requirement->getTestMessage(), $lineSize - 3, PHP_EOL.' ').PHP_EOL;
84+
$errorMessage .= ' > '.wordwrap($requirement->getHelpText(), $lineSize - 5, PHP_EOL.' > ').PHP_EOL;
85+
86+
return $errorMessage;
87+
}
88+
89+
function echo_title($title, $style = null)
90+
{
91+
$style = $style ?: 'title';
92+
93+
echo PHP_EOL;
94+
echo_style($style, $title.PHP_EOL);
95+
echo_style($style, str_repeat('~', strlen($title)).PHP_EOL);
96+
echo PHP_EOL;
97+
}
98+
99+
function echo_style($style, $message)
100+
{
101+
// ANSI color codes
102+
$styles = array(
103+
'reset' => "\033[0m",
104+
'red' => "\033[31m",
105+
'green' => "\033[32m",
106+
'yellow' => "\033[33m",
107+
'error' => "\033[37;41m",
108+
'success' => "\033[37;42m",
109+
'title' => "\033[34m",
110+
);
111+
$supports = has_color_support();
112+
113+
echo($supports ? $styles[$style] : '').$message.($supports ? $styles['reset'] : '');
114+
}
115+
116+
function echo_block($style, $title, $message)
117+
{
118+
$message = ' '.trim($message).' ';
119+
$width = strlen($message);
120+
121+
echo PHP_EOL.PHP_EOL;
122+
123+
echo_style($style, str_repeat(' ', $width));
124+
echo PHP_EOL;
125+
echo_style($style, str_pad(' ['.$title.']', $width, ' ', STR_PAD_RIGHT));
126+
echo PHP_EOL;
127+
echo_style($style, $message);
128+
echo PHP_EOL;
129+
echo_style($style, str_repeat(' ', $width));
130+
echo PHP_EOL;
131+
}
132+
133+
function has_color_support()
134+
{
135+
static $support;
136+
137+
if (null === $support) {
138+
if (DIRECTORY_SEPARATOR == '\\') {
139+
$support = false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI');
140+
} else {
141+
$support = function_exists('posix_isatty') && @posix_isatty(STDOUT);
142+
}
143+
}
144+
145+
return $support;
146+
}

config-enterprise.ru

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'sidekiq-ent'
2+
require 'sidekiq-ent/web'
3+
require 'sidekiq-statistic'
4+
5+
run Rack::URLMap.new(
6+
'/' => Sidekiq::Web
7+
);

sidekiq-enterprise.rb

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
require 'redis'
2+
require 'redis-namespace'
3+
require 'statsd-ruby'
4+
require 'sidekiq'
5+
require 'sidekiq/api'
6+
require 'sidekiq-ent'
7+
require 'base64'
8+
require 'zlib'
9+
require 'stringio'
10+
require 'sidekiq-statistic'
11+
require 'sidekiq-limit_fetch'
12+
13+
Dir[File.dirname(__FILE__) + '/app/workers/*.rb'].each {|file| require file }
14+
15+
Sidekiq::Statistic.configure do |config|
16+
config.log_file = 'app/logs/sidekiq-statistic.log'
17+
end
18+
19+
ENV['RAILS_ENV'] = ENV['RAILS_ENV'] != "development" ? ENV['RAILS_ENV'] : "devbox"
20+
21+
22+
# Redis connection
23+
if ENV['RAILS_ENV'] == 'production'
24+
rediscfg = { url: 'redis://127.0.0.1:6379/0' }
25+
else
26+
rediscfg = { url: 'redis://127.0.0.1:6379/0' }
27+
end
28+
29+
Sidekiq.configure_client do |config|
30+
config.redis = rediscfg
31+
end
32+
33+
Sidekiq.configure_server do |config|
34+
config.redis = rediscfg
35+
config.super_fetch!
36+
config.reliable_scheduler!
37+
config.average_scheduled_poll_interval = 1
38+
39+
# Sending metrics to DataDog
40+
METRICS = Statsd.new('127.0.0.1', 8125)
41+
config.server_middleware do |chain|
42+
require 'sidekiq/middleware/server/statsd'
43+
chain.add Sidekiq::Middleware::Server::Statsd, :client => METRICS
44+
end
45+
46+
# Register cronjobs from yaml
47+
config.periodic do |mgr|
48+
crons_file = File.dirname(__FILE__) + '/app/config/crontab_'+ENV['RAILS_ENV']+'.yml'
49+
crons = File.file?(crons_file) ? YAML.load_file(crons_file) : []
50+
51+
if crons && crons.any?
52+
crons.each { |job|
53+
begin
54+
mgr.register(job['cron'], job['job_class'], args: job['args'], queue: job['queue'])
55+
rescue Exception
56+
raise "\n\nProperties missing or wrong format in crontab.yml\n\n"
57+
end
58+
}
59+
end
60+
61+
end
62+
end
63+
64+
def gzip(string)
65+
wio = StringIO.new("w")
66+
w_gz = Zlib::GzipWriter.new(wio)
67+
w_gz.write(string)
68+
w_gz.close
69+
compressed = wio.string
70+
end

src/DLabs/UserBundle/Resources/config/queue_handler.yml

-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ services:
22
dlabs.user.queue_handler.do_nothing:
33
class: DLabs\UserBundle\Service\QueueHandler\DoNothingQueueHandler
44

5-

0 commit comments

Comments
 (0)