mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 09:37:26 +00:00
lbry log upload
This commit is contained in:
parent
349596d4a9
commit
70233a6e34
9 changed files with 2512 additions and 3 deletions
|
@ -45,6 +45,8 @@ class Controller
|
|||
return ContentActions::executeGet();
|
||||
case '/postcommit':
|
||||
return OpsActions::executePostCommit();
|
||||
case '/log-upload':
|
||||
return OpsActions::executeLogUpload();
|
||||
case '/list-subscribe':
|
||||
return MailActions::executeListSubscribe();
|
||||
case '/LBRY-deck.pdf':
|
||||
|
|
|
@ -26,4 +26,31 @@ class OpsActions extends Actions
|
|||
|
||||
return [null, []];
|
||||
}
|
||||
|
||||
public static function executeLogUpload()
|
||||
{
|
||||
$log = isset($_POST['log']) ? urldecode($_POST['log']) : null;
|
||||
$name = isset($_POST['name']) ?
|
||||
preg_replace('/[^a-z0-9_-]+/', '', substr(strtolower(trim(urldecode($_POST['name']))),0,50)) :
|
||||
null;
|
||||
|
||||
Actions::returnErrorIf(!$log || !$name, "Required params: log, name");
|
||||
|
||||
$awsKey = Config::get('aws_log_access_key');
|
||||
$awsSecret = Config::get('aws_log_secret_key');
|
||||
|
||||
Actions::returnErrorIf(!$awsKey || !$awsSecret, "Missing AWS credentials");
|
||||
|
||||
$tmpFile = tempnam(sys_get_temp_dir(), 'lbryinstalllog');
|
||||
file_put_contents($tmpFile, $log);
|
||||
|
||||
Actions::returnErrorIf(filesize($tmpFile) > 1024*1024*2, "File is too large");
|
||||
|
||||
S3::$useExceptions = true;
|
||||
S3::setAuth($awsKey, $awsSecret);
|
||||
S3::putObject(S3::inputFile($tmpFile, false), 'lbry-install-logs', $name);
|
||||
unlink($tmpFile);
|
||||
|
||||
return [null, []];
|
||||
}
|
||||
}
|
||||
|
|
3
dev.sh
Executable file
3
dev.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
php --server localhost:8000 --docroot web/
|
75
lib/tools/Debug.class.php
Normal file
75
lib/tools/Debug.class.php
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
class Debug
|
||||
{
|
||||
public static function exceptionToString(Exception $e)
|
||||
{
|
||||
return static::getExceptionMessageWithoutTrace($e) . "\n" . static::getFullTrace($e);
|
||||
}
|
||||
|
||||
public static function getExceptionMessageWithoutTrace(Exception $e)
|
||||
{
|
||||
return 'exception \'' . get_class($e) . '\' with message \'' . $e->getMessage() . '\' in ' . $e->getFile() . ':' . $e->getLine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as the normal getTraceAsString(), but does not truncate long lines.
|
||||
* @param Exception $exception
|
||||
* @return string
|
||||
* @see http://stackoverflow.com/questions/1949345/how-can-i-get-the-full-string-of-phps-gettraceasstring/6076667#6076667
|
||||
* @see https://gist.github.com/1437966
|
||||
*/
|
||||
public static function getFullTrace(Exception $exception)
|
||||
{
|
||||
$rtn = '';
|
||||
foreach ($exception->getTrace() as $count => $frame)
|
||||
{
|
||||
$args = isset($frame['args']) ? static::exceptionFrameArgsToString($frame['args']) : '';
|
||||
|
||||
$rtn .= sprintf("#%s %s(%s): %s(%s)\n",
|
||||
$count,
|
||||
isset($frame['file']) ? $frame['file'] : 'unknown file',
|
||||
isset($frame['line']) ? $frame['line'] : 'unknown line',
|
||||
isset($frame['class']) ? $frame['class'].$frame['type'].$frame['function'] : $frame['function'],
|
||||
$args);
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
public static function exceptionFrameArgsToString($args)
|
||||
{
|
||||
$ret = [];
|
||||
foreach ($args as $arg)
|
||||
{
|
||||
if (is_string($arg))
|
||||
{
|
||||
$ret[] = "'" . $arg . "'";
|
||||
}
|
||||
elseif (is_array($arg))
|
||||
{
|
||||
$ret[] = 'Array(' . count($arg) . ')';
|
||||
}
|
||||
elseif (is_null($arg))
|
||||
{
|
||||
$ret[] = 'NULL';
|
||||
}
|
||||
elseif (is_bool($arg))
|
||||
{
|
||||
$ret[] = ($arg) ? 'true' : 'false';
|
||||
}
|
||||
elseif (is_object($arg))
|
||||
{
|
||||
$ret[] = get_class($arg) . (!($arg instanceof Closure) && isset($arg->id) ? "({$arg->id})" : '');
|
||||
}
|
||||
elseif (is_resource($arg))
|
||||
{
|
||||
$ret[] = get_resource_type($arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret[] = $arg;
|
||||
}
|
||||
}
|
||||
return join(', ', $ret);
|
||||
}
|
||||
}
|
2389
lib/vendor/S3.class.php
vendored
Normal file
2389
lib/vendor/S3.class.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -5,6 +5,19 @@ include __DIR__ . '/../bootstrap.php';
|
|||
|
||||
define('IS_PRODUCTION', $_SERVER['SERVER_NAME'] == 'lbry.io');
|
||||
|
||||
i18n::register();
|
||||
Session::init();
|
||||
Controller::dispatch(strtok($_SERVER['REQUEST_URI'], '?'));
|
||||
try
|
||||
{
|
||||
i18n::register();
|
||||
Session::init();
|
||||
Controller::dispatch(strtok($_SERVER['REQUEST_URI'], '?'));
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
if (IS_PRODUCTION)
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
|
||||
http_response_code(500);
|
||||
echo '<pre>'.Debug::exceptionToString($e).'</pre>';
|
||||
}
|
BIN
web/osx.dmg
BIN
web/osx.dmg
Binary file not shown.
Loading…
Add table
Reference in a new issue