dockerise server

This commit is contained in:
Jurgis Sakalauskas
2023-08-04 16:06:47 +03:00
parent 27f76a08f0
commit fe938afa3f
11 changed files with 81 additions and 28 deletions
+4 -1
View File
@@ -322,7 +322,10 @@ export class TorrentService {
const torrId = parseInt(id);
const result = await this.torrSeedClient
.addTorrentById(torrId)
.catch(() => false);
.catch((e) => {
console.log(e);
return false;
});
return new NotificationResponse(
result ? 'torrent added to transmission' : 'adding failed',
@@ -29,7 +29,10 @@ export class TorrentSeedClient {
return Promise.reject('torrent not found');
}
const torrInfo = await this.addTorrent(torrentEntity).catch(() => null);
const torrInfo = await this.addTorrent(torrentEntity).catch((e) => {
console.log(e);
return null;
});
if (torrInfo) {
await this.torrentRepository.update(
+1 -1
View File
@@ -13,7 +13,7 @@ export class ConfigService {
private videoFilesConfig: VideoFilesConfig = new VideoFilesConfig(this);
private recentSearches: RecentSearchesConfig = new RecentSearchesConfig(this);
public getEnv(key: string): any {
public getEnv(key: string): string {
return process.env[key];
}
+5 -2
View File
@@ -7,11 +7,14 @@ export class PathsConfig {
}
public getStaticRequestsLogPath(): string {
return this.getPathByEnvKey('LOG_FILE_REQUESTS');
return join(
'/srv/data/requests-log',
this.configService.getEnv('LOG_FILE_REQUESTS_NAME'),
);
}
public getStaticFolder(): string {
return this.getPathByEnvKey('STATIC_SERVE_FOLDER');
return '/srv/data/static';
}
public getPathByEnvKey(key: string) {
+1 -3
View File
@@ -6,9 +6,7 @@ export class RecentSearchesConfig {
}
public getRecentSearchesFolder(): string {
return this.configService
.getPaths()
.getPathByEnvKey('RECENT_SEARCHES_FOLDER');
return '/srv/data/recent-searches';
}
public getRecentSearchesLimit(): number {
+2 -1
View File
@@ -4,11 +4,12 @@ import { EntityClassOrSchema } from '@nestjs/typeorm/dist/interfaces/entity-clas
import { TitleEntity } from '../Shared/Entity/title.entity';
import { FileEntity } from '../Shared/Entity/file.entity';
import { TorrentEntity } from '../Shared/Entity/torrent.entity';
import { join } from 'path';
export class TypeOrmConfig {
constructor(configService: ConfigService) {
this.type = 'sqlite';
this.database = configService.getEnv('DB_PATH');
this.database = join('/srv/data/db', configService.getEnv('DB_FILENAME'));
this.entities = [LrtCategory, TitleEntity, FileEntity, TorrentEntity];
}
type: 'sqlite';
+4 -6
View File
@@ -6,7 +6,7 @@ export class VideoFilesConfig {
}
public getVideoFilesFolders(): string[] {
return JSON.parse(this.configService.getEnv('VIDEO_FILES_FOLDERS'));
return [this.configService.getEnv('VIDEO_FILES_FOLDER')];
}
public getVideoFilesExt(): string[] {
@@ -18,17 +18,15 @@ export class VideoFilesConfig {
}
public getTorrentDownloadDir(): string {
return this.configService
.getPaths()
.getPathByEnvKey('TORRENT_DOWNLOAD_DIR');
return this.configService.getEnv('VIDEO_FILES_FOLDER');
}
public getTransmissionOptions() {
return {
host: this.configService.getEnv('TRANSMISSION_CLIENT_HOST'), // # default 'localhost'
//port: 9091, // # default 9091
//username: "username", // # default blank
//password: "password", // # default blank
username: this.configService.getEnv('TRANSMISSION_CLIENT_USER'), // # default blank
password: this.configService.getEnv('TRANSMISSION_CLIENT_PASSWORD'), // # default blank
//ssl: true, //# default false use https
//url: "/my/other/url" // # default '/transmission/rpc'
};