Skip to content

Commit 322e0d2

Browse files
authored
Merge pull request #84 from topcoder-platform/issues-519
Issues-519: read tideways logs
2 parents 3adaa1a + 7f7e852 commit 322e0d2

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
use Garden\Web\Exception\ClientException;
4+
use Garden\Schema\Schema;
5+
use Vanilla\Utility\InstanceValidatorSchema;
6+
use Garden\Web\Data;
7+
use Garden\Web\Exception\NotFoundException;
8+
use Garden\Web\Exception\ServerException;
9+
use Vanilla\ApiUtils;
10+
11+
/**
12+
* SQL API Controller for the `/service` resource.
13+
*/
14+
class ServiceApiController extends AbstractApiController {
15+
/**
16+
*
17+
* @param array $query The query string.
18+
* @return Data
19+
*/
20+
public function get_tidewayslog($path='/var/log/tideways/daemon.log') {
21+
$this->permission('Garden.Settings.Manage');
22+
23+
if (file_exists($path)) {
24+
//Get file type and set it as Content Type
25+
$finfo = finfo_open(FILEINFO_MIME_TYPE);
26+
header('Content-Type: ' . finfo_file($finfo, $path));
27+
finfo_close($finfo);
28+
29+
header('Content-Description: File Transfer');
30+
header('Content-Disposition: attachment; filename='.basename($path));
31+
header('Expires: 0');
32+
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
33+
header('Pragma: public');
34+
header('Content-Length: ' . filesize($path));
35+
ob_clean();
36+
flush();
37+
readfile($path);
38+
exit;
39+
} else {
40+
throw notFoundException('File');
41+
}
42+
}
43+
44+
}

DebugPlugin/openapi/service.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
openapi: 3.0.2
2+
info: Vanilla Service API
3+
paths:
4+
/service/tidewayslog:
5+
get:
6+
responses:
7+
'200':
8+
content:
9+
'text/plain':
10+
schema:
11+
type: string
12+
description: Success
13+
tags:
14+
- Services
15+
summary: File.

0 commit comments

Comments
 (0)