Compare commits
45 Commits
Author | SHA1 | Date | |
---|---|---|---|
2a007df722 | |||
|
73b15ce781 | ||
3e50146f5e | |||
5d36c40508 | |||
12f81cb014 | |||
8c0c52c736 | |||
bd8e36d893 | |||
dacd86039d | |||
af41be829a | |||
1c08196104 | |||
7b23fa248b | |||
095e5c2a84 | |||
0c77a7ab04 | |||
cfb1d09eb7 | |||
bd4117df38 | |||
0eaf18822b | |||
7bdd4a5dfb | |||
ea6e6c95e1 | |||
c7f9c4cf73 | |||
ce9efc463d | |||
879ff8f8f4 | |||
f132861cbc | |||
47e8ec4f43 | |||
c0c96c7a51 | |||
8cb640d804 | |||
1189f4b61c | |||
0f5b9eb45a | |||
9a567b7178 | |||
88f63e040e | |||
aabf1d49a7 | |||
3b789eb623 | |||
ad0115e5f2 | |||
3c6079807e | |||
b21d98ef73 | |||
2e55876076 | |||
dad3e6c1cf | |||
8c36855593 | |||
6bce649458 | |||
d017cb19f3 | |||
5bc2acac1d | |||
fe29664a83 | |||
5e8da26257 | |||
763c27ca95 | |||
a8302c38e0 | |||
a977ff8cfe |
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@
|
|||||||
.settings/
|
.settings/
|
||||||
target/
|
target/
|
||||||
.idea/
|
.idea/
|
||||||
|
logs/
|
||||||
|
@ -1,14 +1,23 @@
|
|||||||
pipeline:
|
pipeline:
|
||||||
test:
|
test:
|
||||||
image: maven:3-jdk-11
|
image: maven:3-eclipse-temurin-17-alpine
|
||||||
commands:
|
commands:
|
||||||
|
- apk add lsof
|
||||||
- mvn test
|
- mvn test
|
||||||
|
|
||||||
build:
|
build:
|
||||||
image: maven:3-jdk-11
|
image: maven:3-eclipse-temurin-17-alpine
|
||||||
commands:
|
commands:
|
||||||
- mvn clean compile assembly:single
|
- mvn clean compile assembly:single
|
||||||
|
|
||||||
|
package:
|
||||||
|
image: maven:3-eclipse-temurin-17-alpine
|
||||||
|
commands:
|
||||||
|
- apk add rpm
|
||||||
|
- mvn clean compile package -Dmaven.test.skip
|
||||||
|
when:
|
||||||
|
event: tag
|
||||||
|
|
||||||
gitea_release:
|
gitea_release:
|
||||||
image: plugins/gitea-release
|
image: plugins/gitea-release
|
||||||
settings:
|
settings:
|
||||||
@ -17,6 +26,54 @@ pipeline:
|
|||||||
base_url: https://git.metaunix.net
|
base_url: https://git.metaunix.net
|
||||||
title: "${CI_COMMIT_TAG}"
|
title: "${CI_COMMIT_TAG}"
|
||||||
files:
|
files:
|
||||||
- target/Dragoon-*.jar
|
- target/dragoon-*.jar
|
||||||
|
- target/dragoon-*.deb
|
||||||
|
- target/rpm/dragoon/RPMS/noarch/dragoon-*.rpm
|
||||||
|
when:
|
||||||
|
event: tag
|
||||||
|
|
||||||
|
copy_deb_package:
|
||||||
|
image: appleboy/drone-scp
|
||||||
|
settings:
|
||||||
|
host: "repo.int.metaunix.net"
|
||||||
|
username:
|
||||||
|
from_secret: repo_admin
|
||||||
|
password:
|
||||||
|
from_secret: repo_password
|
||||||
|
port: 22
|
||||||
|
target: /srv/repo/apt/dragoon/
|
||||||
|
source: target/dragoon-*.deb
|
||||||
|
strip_components: 1
|
||||||
|
when:
|
||||||
|
event: tag
|
||||||
|
|
||||||
|
copy_rpm_package:
|
||||||
|
image: appleboy/drone-scp
|
||||||
|
settings:
|
||||||
|
host: "repo.int.metaunix.net"
|
||||||
|
username:
|
||||||
|
from_secret: repo_admin
|
||||||
|
password:
|
||||||
|
from_secret: repo_password
|
||||||
|
port: 22
|
||||||
|
target: /srv/repo/dnf/dragoon/
|
||||||
|
source: target/rpm/dragoon/RPMS/noarch/dragoon-*.rpm
|
||||||
|
strip_components: 5
|
||||||
|
when:
|
||||||
|
event: tag
|
||||||
|
|
||||||
|
update_repos:
|
||||||
|
image: appleboy/drone-ssh
|
||||||
|
settings:
|
||||||
|
host:
|
||||||
|
- repo.int.metaunix.net
|
||||||
|
username:
|
||||||
|
from_secret: repo_admin
|
||||||
|
password:
|
||||||
|
from_secret: repo_password
|
||||||
|
port: 22
|
||||||
|
command_timeout: 2m
|
||||||
|
script:
|
||||||
|
- sudo /home/xadmin/scripts/update_repo.sh
|
||||||
when:
|
when:
|
||||||
event: tag
|
event: tag
|
||||||
|
32
README.md
32
README.md
@ -2,19 +2,41 @@
|
|||||||
|
|
||||||
The Bit Goblin video transcoder.
|
The Bit Goblin video transcoder.
|
||||||
|
|
||||||
|
## Installing from RPM
|
||||||
|
|
||||||
|
Installing from the Bit Goblin repository is easy! Add the following repo file to `/etc/yum.repos.d/bitgoblin.repo`:
|
||||||
|
|
||||||
|
```
|
||||||
|
[bitgoblin]
|
||||||
|
name=Bit Goblin repository
|
||||||
|
baseurl=http://repo.metaunix.net/dnf
|
||||||
|
enabled=1
|
||||||
|
gpgcheck=0
|
||||||
|
```
|
||||||
|
|
||||||
|
Update your package sources just to make sure all was added properly:
|
||||||
|
|
||||||
|
```
|
||||||
|
dnf updateinfo
|
||||||
|
```
|
||||||
|
|
||||||
|
Then install dragoon! Use the command below if you DON'T want DNF to install a bunch of unnecessary stuff to meet OpenJDK's weak dependencies; otherwise a regular `dnf install dragoon` is fine:
|
||||||
|
|
||||||
|
```
|
||||||
|
dnf --setopt=install_weak_deps=False --best install dragoon
|
||||||
|
```
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
Currently this project is targeting Java 11 LTS and uses Maven to manage the software lifecycle. Thus, you must have a Java 11 JDK and Maven installed to build this project.
|
Currently this project is targeting Java 17 LTS and uses Maven to manage the software lifecycle. Thus, you must have a Java 17 JDK and Maven installed to build this project.
|
||||||
|
|
||||||
*NOTE:* The targeted Java version will likely change to 17 LTS soon.
|
|
||||||
|
|
||||||
### Ubuntu
|
### Ubuntu
|
||||||
|
|
||||||
`sudo apt install openjdk-11-jdk maven`
|
`sudo apt install openjdk-17-jdk maven`
|
||||||
|
|
||||||
### Red Hat/Almalinux
|
### Red Hat/Almalinux
|
||||||
|
|
||||||
`sudo dnf install java-11-openjdk-devel maven`
|
`sudo dnf install java-17-openjdk-devel maven`
|
||||||
|
|
||||||
### Actually Building
|
### Actually Building
|
||||||
|
|
||||||
|
320
pom.xml
320
pom.xml
@ -5,24 +5,63 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>tech.bitgoblin</groupId>
|
<groupId>tech.bitgoblin</groupId>
|
||||||
<artifactId>Dragoon</artifactId>
|
<artifactId>dragoon</artifactId>
|
||||||
<version>0.2.0</version>
|
<version>0.3.12</version>
|
||||||
|
|
||||||
<name>Dragoon</name>
|
<name>Dragoon</name>
|
||||||
<url>https://www.bitgoblin.tech</url>
|
<url>https://www.bitgoblin.tech</url>
|
||||||
|
<description>Automated video transcoder service.</description>
|
||||||
|
<inceptionYear>2022</inceptionYear>
|
||||||
|
|
||||||
|
<organization>
|
||||||
|
<name>Bit Goblin</name>
|
||||||
|
<url>https://www.bitgoblin.tech</url>
|
||||||
|
</organization>
|
||||||
|
|
||||||
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<id>gballantine</id>
|
||||||
|
<name>Gregory Ballantine</name>
|
||||||
|
<email>gballantine@bitgoblin.tech</email>
|
||||||
|
</developer>
|
||||||
|
</developers>
|
||||||
|
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>BSD</name>
|
||||||
|
<url>https://opensource.org/licenses/BSD-2-Clause</url>
|
||||||
|
<distribution>repo</distribution>
|
||||||
|
<comments>Simplified BSD license.</comments>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-cli</groupId>
|
||||||
|
<artifactId>commons-cli</artifactId>
|
||||||
|
<version>1.3.1</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.tomlj</groupId>
|
<groupId>org.tomlj</groupId>
|
||||||
<artifactId>tomlj</artifactId>
|
<artifactId>tomlj</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-api</artifactId>
|
||||||
|
<version>2.19.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
<version>2.19.0</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
@ -32,81 +71,202 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
|
<plugins>
|
||||||
<plugins>
|
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
|
||||||
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
|
<plugin>
|
||||||
<plugin>
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
<artifactId>maven-clean-plugin</artifactId>
|
<version>3.1.0</version>
|
||||||
<version>3.1.0</version>
|
</plugin>
|
||||||
</plugin>
|
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
|
||||||
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
|
<plugin>
|
||||||
<plugin>
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<version>3.0.2</version>
|
||||||
<version>3.0.2</version>
|
</plugin>
|
||||||
</plugin>
|
<plugin>
|
||||||
<plugin>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<version>3.8.0</version>
|
||||||
<version>3.8.0</version>
|
</plugin>
|
||||||
</plugin>
|
<plugin>
|
||||||
<plugin>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<version>2.22.1</version>
|
||||||
<version>2.22.1</version>
|
</plugin>
|
||||||
</plugin>
|
<plugin>
|
||||||
<plugin>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<version>3.0.2</version>
|
||||||
<version>3.0.2</version>
|
<configuration>
|
||||||
<configuration>
|
<!-- DO NOT include log4j.properties file in your Jar -->
|
||||||
<!-- DO NOT include log4j.properties file in your Jar -->
|
<excludes>
|
||||||
<excludes>
|
<exclude>**/log4j.properties</exclude>
|
||||||
<exclude>**/log4j.properties</exclude>
|
</excludes>
|
||||||
</excludes>
|
<archive>
|
||||||
<archive>
|
<manifest>
|
||||||
<manifest>
|
<!-- Jar file entry point -->
|
||||||
<!-- Jar file entry point -->
|
<mainClass>tech.bitgoblin.App</mainClass>
|
||||||
<mainClass>tech.bitgoblin.App</mainClass>
|
</manifest>
|
||||||
</manifest>
|
</archive>
|
||||||
</archive>
|
</configuration>
|
||||||
</configuration>
|
</plugin>
|
||||||
</plugin>
|
<plugin>
|
||||||
<plugin>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<executions>
|
||||||
<executions>
|
<execution>
|
||||||
<execution>
|
<phase>package</phase>
|
||||||
<phase>package</phase>
|
<goals>
|
||||||
<goals>
|
<goal>single</goal>
|
||||||
<goal>single</goal>
|
</goals>
|
||||||
</goals>
|
</execution>
|
||||||
</execution>
|
</executions>
|
||||||
</executions>
|
<configuration>
|
||||||
<configuration>
|
<archive>
|
||||||
<archive>
|
<manifest>
|
||||||
<manifest>
|
<mainClass>tech.bitgoblin.App</mainClass>
|
||||||
<mainClass>tech.bitgoblin.App</mainClass>
|
</manifest>
|
||||||
</manifest>
|
</archive>
|
||||||
</archive>
|
<descriptorRefs>
|
||||||
<descriptorRefs>
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
</descriptorRefs>
|
||||||
</descriptorRefs>
|
</configuration>
|
||||||
</configuration>
|
</plugin>
|
||||||
</plugin>
|
<plugin>
|
||||||
<plugin>
|
<groupId>com.aerse.maven</groupId>
|
||||||
<artifactId>maven-install-plugin</artifactId>
|
<artifactId>deb-maven-plugin</artifactId>
|
||||||
<version>2.5.2</version>
|
<version>1.16</version>
|
||||||
</plugin>
|
<executions>
|
||||||
<plugin>
|
<execution>
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
<id>package</id>
|
||||||
<version>2.8.2</version>
|
<phase>package</phase>
|
||||||
</plugin>
|
<goals>
|
||||||
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
|
<goal>package</goal>
|
||||||
<plugin>
|
</goals>
|
||||||
<artifactId>maven-site-plugin</artifactId>
|
</execution>
|
||||||
<version>3.7.1</version>
|
</executions>
|
||||||
</plugin>
|
<configuration>
|
||||||
<plugin>
|
<unixUserId>dragoon</unixUserId>
|
||||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
<unixGroupId>dragoon</unixGroupId>
|
||||||
<version>3.0.0</version>
|
<debBaseDir>${project.basedir}/src/build/deb</debBaseDir>
|
||||||
</plugin>
|
<installDir>/opt</installDir>
|
||||||
</plugins>
|
<osDependencies>
|
||||||
</pluginManagement>
|
<openjdk-17-jre></openjdk-17-jre>
|
||||||
|
<ffmpeg></ffmpeg>
|
||||||
|
</osDependencies>
|
||||||
|
<javaServiceWrapper>false</javaServiceWrapper>
|
||||||
|
<generateVersion>false</generateVersion>
|
||||||
|
<fileSets>
|
||||||
|
<fileSet>
|
||||||
|
<source>${basedir}/src/build/deb</source>
|
||||||
|
<target>/</target>
|
||||||
|
</fileSet>
|
||||||
|
<fileSet>
|
||||||
|
<source>${basedir}/target/dragoon-${project.version}-jar-with-dependencies.jar</source>
|
||||||
|
<target>/opt/dragoon/dragoon.jar</target>
|
||||||
|
</fileSet>
|
||||||
|
</fileSets>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>rpm-maven-plugin</artifactId>
|
||||||
|
<version>2.2.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>generate-rpm</id>
|
||||||
|
<goals>
|
||||||
|
<goal>rpm</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<license>BSD 2-Clause</license>
|
||||||
|
<group>Applications/Multimedia</group>
|
||||||
|
<icon>src/main/resources/icon.gif</icon>
|
||||||
|
<packager>Bit Goblin</packager>
|
||||||
|
<prefix>/opt</prefix>
|
||||||
|
<changelogFile>${project.basedir}/src/build/changelog.txt</changelogFile>
|
||||||
|
<targetOs>linux</targetOs>
|
||||||
|
<mappings>
|
||||||
|
<mapping>
|
||||||
|
<directory>/opt/dragoon</directory>
|
||||||
|
<filemode>755</filemode>
|
||||||
|
<username>dragoon</username>
|
||||||
|
<groupname>dragoon</groupname>
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<directory>/opt/dragoon/dragoon.jar</directory>
|
||||||
|
<filemode>755</filemode>
|
||||||
|
<username>dragoon</username>
|
||||||
|
<groupname>dragoon</groupname>
|
||||||
|
<sources>
|
||||||
|
<source>
|
||||||
|
<location>${basedir}/target/dragoon-${project.version}-jar-with-dependencies.jar</location>
|
||||||
|
</source>
|
||||||
|
</sources>
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<directory>/opt/dragoon/log4j2.xml</directory>
|
||||||
|
<filemode>755</filemode>
|
||||||
|
<username>dragoon</username>
|
||||||
|
<groupname>dragoon</groupname>
|
||||||
|
<sources>
|
||||||
|
<source>
|
||||||
|
<location>${basedir}/src/build/deb/opt/dragoon/log4j2.xml</location>
|
||||||
|
</source>
|
||||||
|
</sources>
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<directory>/etc/dragoon</directory>
|
||||||
|
<configuration>true</configuration>
|
||||||
|
<filemode>755</filemode>
|
||||||
|
<username>dragoon</username>
|
||||||
|
<groupname>dragoon</groupname>
|
||||||
|
<sources>
|
||||||
|
<source>
|
||||||
|
<location>${project.basedir}/src/build/deb/etc/dragoon</location>
|
||||||
|
</source>
|
||||||
|
</sources>
|
||||||
|
</mapping>
|
||||||
|
<mapping>
|
||||||
|
<directory>/etc/systemd/system/dragoon.service</directory>
|
||||||
|
<filemode>644</filemode>
|
||||||
|
<username>root</username>
|
||||||
|
<groupname>root</groupname>
|
||||||
|
<sources>
|
||||||
|
<source>
|
||||||
|
<location>${project.basedir}/src/build/deb/etc/systemd/system/dragoon.service</location>
|
||||||
|
</source>
|
||||||
|
</sources>
|
||||||
|
</mapping>
|
||||||
|
</mappings>
|
||||||
|
<requires>
|
||||||
|
<require>java-17-openjdk</require>
|
||||||
|
<require>ffmpeg-free</require>
|
||||||
|
</requires>
|
||||||
|
<preinstallScriptlet>
|
||||||
|
<script>echo "installing ${project.name} now"</script>
|
||||||
|
</preinstallScriptlet>
|
||||||
|
<postinstallScriptlet>
|
||||||
|
<scriptFile>src/build/scripts/postinstall.sh</scriptFile>
|
||||||
|
<fileEncoding>utf-8</fileEncoding>
|
||||||
|
<filter>true</filter>
|
||||||
|
</postinstallScriptlet>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-install-plugin</artifactId>
|
||||||
|
<version>2.5.2</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
<version>2.8.2</version>
|
||||||
|
</plugin>
|
||||||
|
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-site-plugin</artifactId>
|
||||||
|
<version>3.7.1</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
1
src/build/changelog.txt
Normal file
1
src/build/changelog.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
# Check https://git.metaunix.net/bitgoblin/dragoon/releases for the current changelog
|
9
src/build/deb/etc/dragoon/config.example.toml
Normal file
9
src/build/deb/etc/dragoon/config.example.toml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# This example transcodes footage to DNxHD 1080p60 for use in video editors like DaVinci Resolve.
|
||||||
|
[transcoder]
|
||||||
|
repo_path = '~/videos' # location of the videos to transcode
|
||||||
|
interval = 30
|
||||||
|
video_format = 'mov' # video container format
|
||||||
|
video_codec = 'dnxhd' # video codec to use
|
||||||
|
video_parameters = 'scale=1920x1080,fps=60,format=yuv422p' # video extra format parameters flag - this will be broken later into separate attributes
|
||||||
|
video_profile = 'dnxhr_hq' # DNxHD has multiple presets for various video qualities
|
||||||
|
audio_codec = 'pcm_s16le' # audio codec to use
|
11
src/build/deb/etc/systemd/system/dragoon.service
Normal file
11
src/build/deb/etc/systemd/system/dragoon.service
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Dragoon video transcoder service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=dragoon
|
||||||
|
Group=dragoon
|
||||||
|
ExecStart=/usr/bin/java -Dlog4j.configurationFile=/opt/dragoon/log4j2.xml -jar '/opt/dragoon/dragoon.jar' -c '/etc/dragoon/config.toml'
|
||||||
|
SuccessExitStatus=143
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
20
src/build/deb/opt/dragoon/log4j2.xml
Normal file
20
src/build/deb/opt/dragoon/log4j2.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Configuration status="info" name="Dragoon" packages="">
|
||||||
|
<Appenders>
|
||||||
|
<File name="DragoonLog" fileName="/opt/dragoon/logs/dragoon.log">
|
||||||
|
<PatternLayout>
|
||||||
|
<Pattern>%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n</Pattern>
|
||||||
|
</PatternLayout>
|
||||||
|
</File>
|
||||||
|
<Console name="Console" target="SYSTEM_OUT">
|
||||||
|
<PatternLayout
|
||||||
|
pattern="%highlight{%d [%t] %-5level: %msg%n%throwable}" />
|
||||||
|
</Console>
|
||||||
|
</Appenders>
|
||||||
|
<Loggers>
|
||||||
|
<Root level="info">
|
||||||
|
<AppenderRef ref="DragoonLog"/>
|
||||||
|
<AppenderRef ref="Console"/>
|
||||||
|
</Root>
|
||||||
|
</Loggers>
|
||||||
|
</Configuration>
|
23
src/build/scripts/postinstall.sh
Normal file
23
src/build/scripts/postinstall.sh
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
GETENT_USER=$(getent passwd dragoon)
|
||||||
|
GETENT_GROUP=$(getent group dragoon)
|
||||||
|
|
||||||
|
# Create the dragoon user if it doesn't already exist
|
||||||
|
if [ "$GETENT_USER" = "" ]; then
|
||||||
|
useradd -r dragoon
|
||||||
|
else
|
||||||
|
echo "The 'dragoon' user already exists, skipping creation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create the dragoon group if it doesn't already exist
|
||||||
|
if [ "$GETENT_GROUP" = "" ]; then
|
||||||
|
groupadd dragoon
|
||||||
|
usermod -aG dragoon dragoon
|
||||||
|
else
|
||||||
|
echo "The 'dragoon' group already exists, skipping creation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Change the directory ownership of /opt and /etc
|
||||||
|
chown -R dragoon:dragoon /etc/dragoon
|
||||||
|
chown -R dragoon:dragoon /opt/dragoon
|
@ -1,5 +1,7 @@
|
|||||||
package tech.bitgoblin;
|
package tech.bitgoblin;
|
||||||
|
|
||||||
|
import org.apache.commons.cli.ParseException;
|
||||||
|
import tech.bitgoblin.config.Cmd;
|
||||||
import tech.bitgoblin.config.Config;
|
import tech.bitgoblin.config.Config;
|
||||||
import tech.bitgoblin.transcoder.RunTranscoderTask;
|
import tech.bitgoblin.transcoder.RunTranscoderTask;
|
||||||
import tech.bitgoblin.transcoder.Transcoder;
|
import tech.bitgoblin.transcoder.Transcoder;
|
||||||
@ -12,15 +14,20 @@ import java.util.Timer;
|
|||||||
*/
|
*/
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
private static final String configFile = "~/.config/dragoon.toml";
|
private static final int msToMinutes = 60 * 1000;
|
||||||
|
|
||||||
|
public static void main(String[] args) throws ParseException {
|
||||||
|
// parse command-line options
|
||||||
|
Cmd cmd = new Cmd(args);
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// read our config file
|
// read our config file
|
||||||
Config c = new Config(configFile);
|
Config c = new Config(cmd.getConfigPath());
|
||||||
|
|
||||||
// create new Transcoder object and start the service
|
// create new Transcoder object and start the service
|
||||||
Transcoder t = new Transcoder(c);
|
Transcoder t = new Transcoder(c);
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
timer.scheduleAtFixedRate(new RunTranscoderTask(t), 2500, 120 * 1000);
|
timer.scheduleAtFixedRate(new RunTranscoderTask(t), 2500, ((long) c.getInt("transcoder.interval") * msToMinutes));
|
||||||
|
Logger.logger.info(String.format("Starting transcoder, running in %d minute intervals.", c.getInt("transcoder.interval")));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
9
src/main/java/tech/bitgoblin/Logger.java
Normal file
9
src/main/java/tech/bitgoblin/Logger.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package tech.bitgoblin;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
|
||||||
|
public class Logger {
|
||||||
|
|
||||||
|
public static org.apache.logging.log4j.Logger logger = LogManager.getRootLogger();
|
||||||
|
|
||||||
|
}
|
30
src/main/java/tech/bitgoblin/config/Cmd.java
Normal file
30
src/main/java/tech/bitgoblin/config/Cmd.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package tech.bitgoblin.config;
|
||||||
|
|
||||||
|
import org.apache.commons.cli.*;
|
||||||
|
|
||||||
|
public class Cmd {
|
||||||
|
|
||||||
|
private String configPath = "~/.config/dragoon.toml";
|
||||||
|
|
||||||
|
public Cmd(String[] args) throws ParseException {
|
||||||
|
Options options = new Options();
|
||||||
|
|
||||||
|
Option configPath = new Option("c", "configPath", true, "configuration file path (defaults to /etc/dragoon/config.toml)");
|
||||||
|
configPath.setRequired(false);
|
||||||
|
options.addOption(configPath);
|
||||||
|
|
||||||
|
CommandLineParser parser = new DefaultParser();
|
||||||
|
HelpFormatter formatter = new HelpFormatter();
|
||||||
|
CommandLine cmd = parser.parse(options, args);
|
||||||
|
|
||||||
|
// set the configPath variable if the option was passed to the program
|
||||||
|
if (cmd.hasOption("configPath")) {
|
||||||
|
this.configPath = cmd.getOptionValue("configPath");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConfigPath() {
|
||||||
|
return this.configPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package tech.bitgoblin.config;
|
package tech.bitgoblin.config;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@ -8,6 +7,7 @@ import java.util.Objects;
|
|||||||
|
|
||||||
import org.tomlj.Toml;
|
import org.tomlj.Toml;
|
||||||
import org.tomlj.TomlParseResult;
|
import org.tomlj.TomlParseResult;
|
||||||
|
import tech.bitgoblin.Logger;
|
||||||
import tech.bitgoblin.io.IOUtils;
|
import tech.bitgoblin.io.IOUtils;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
@ -21,7 +21,7 @@ public class Config {
|
|||||||
try {
|
try {
|
||||||
this.parseConfig();
|
this.parseConfig();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("Unable to read config file; please check that " + this.configPath + " is available.");
|
Logger.logger.info("Unable to read config file; please check that " + this.configPath + " is available.");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -31,7 +31,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getInt(String key) {
|
public int getInt(String key) {
|
||||||
return Objects.requireNonNull(this.result.getDouble(key)).intValue();
|
return Objects.requireNonNull(this.result.getLong(key)).intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(String key) {
|
public boolean contains(String key) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package tech.bitgoblin.io;
|
package tech.bitgoblin.io;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
|
|
||||||
public class IOUtils {
|
public class IOUtils {
|
||||||
|
|
||||||
@ -24,4 +24,23 @@ public class IOUtils {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// checks to see if a file is currently locked/being written to.
|
||||||
|
public static boolean isFileLocked(File file) throws IOException {
|
||||||
|
String[] cmd = {"lsof", file.toString()};
|
||||||
|
Process process = Runtime.getRuntime().exec(cmd);
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(
|
||||||
|
process.getInputStream()));
|
||||||
|
|
||||||
|
boolean isOpen = false; // we'll change this if lsof returns that the file is open
|
||||||
|
|
||||||
|
String s;
|
||||||
|
while ((s = reader.readLine()) != null) {
|
||||||
|
if (s.endsWith(file.toString())) {
|
||||||
|
isOpen = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return isOpen;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
70
src/main/java/tech/bitgoblin/transcoder/Repository.java
Normal file
70
src/main/java/tech/bitgoblin/transcoder/Repository.java
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
package tech.bitgoblin.transcoder;
|
||||||
|
|
||||||
|
import tech.bitgoblin.Logger;
|
||||||
|
import tech.bitgoblin.io.IOUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
|
|
||||||
|
public class Repository {
|
||||||
|
|
||||||
|
private String repoPath;
|
||||||
|
private String ingestPath;
|
||||||
|
private String outputPath;
|
||||||
|
private String archivePath;
|
||||||
|
|
||||||
|
public Repository(String repoPath) {
|
||||||
|
this.repoPath = IOUtils.resolveTilda(repoPath);
|
||||||
|
this.ingestPath = Paths.get(this.repoPath, "ingest").toString();
|
||||||
|
this.outputPath = Paths.get(this.repoPath, "output").toString();
|
||||||
|
this.archivePath = Paths.get(this.repoPath, "archive").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// initializes the video repository
|
||||||
|
public void init() {
|
||||||
|
String[] dirs = {this.repoPath, this.ingestPath, this.outputPath, this.archivePath};
|
||||||
|
for (String p : dirs) {
|
||||||
|
IOUtils.createDirectory(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// searches this ingest directory for video files
|
||||||
|
public File[] searchIngest() {
|
||||||
|
Logger.logger.info("Searching for files to transcode in " + this.ingestPath);
|
||||||
|
File repo = new File(this.ingestPath);
|
||||||
|
return repo.listFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
// archives files in the ingest directory
|
||||||
|
public void archiveFile(File sourceFile) {
|
||||||
|
Path filePath = Path.of(sourceFile.toString());
|
||||||
|
String filename = filePath.getFileName().toString();
|
||||||
|
String archivePath = Paths.get(this.archivePath, filename).toString();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Files.copy(filePath, Paths.get(archivePath), StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// clean up the ingest directory once we're done
|
||||||
|
public void cleanupFile(File sourceFile) {
|
||||||
|
sourceFile.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns the repository's path
|
||||||
|
public String getPath() {
|
||||||
|
return this.repoPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the repository's output path
|
||||||
|
public String getOutputPath() {
|
||||||
|
return this.outputPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package tech.bitgoblin.transcoder;
|
package tech.bitgoblin.transcoder;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
public class RunTranscoderTask extends TimerTask {
|
public class RunTranscoderTask extends TimerTask {
|
||||||
@ -13,11 +14,11 @@ public class RunTranscoderTask extends TimerTask {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// archive the files
|
// archive the files
|
||||||
transcoder.archive();
|
try {
|
||||||
// run the transcoder
|
transcoder.run();
|
||||||
transcoder.transcode();
|
} catch (IOException e) {
|
||||||
// clean up ingest
|
throw new RuntimeException(e);
|
||||||
transcoder.cleanup();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,121 +4,96 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.InterruptedException;
|
import java.lang.InterruptedException;
|
||||||
import java.lang.Process;
|
import java.lang.Process;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardCopyOption;
|
|
||||||
import java.util.Timer;
|
|
||||||
|
|
||||||
|
import tech.bitgoblin.Logger;
|
||||||
import tech.bitgoblin.config.Config;
|
import tech.bitgoblin.config.Config;
|
||||||
import tech.bitgoblin.io.IOUtils;
|
import tech.bitgoblin.io.IOUtils;
|
||||||
|
|
||||||
public class Transcoder {
|
public class Transcoder {
|
||||||
|
|
||||||
private String repo_dir;
|
private Repository repo;
|
||||||
private Config config;
|
private Config config;
|
||||||
private String ffmpeg_path = "/usr/bin/ffmpeg";
|
private String ffmpeg_path = "/usr/bin/ffmpeg";
|
||||||
|
|
||||||
// only define the working directory; use default FFMPEG path
|
// only define the working directory; use default FFMPEG path
|
||||||
public Transcoder(Config config) {
|
public Transcoder(Config config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.repo_dir = IOUtils.resolveTilda(this.config.getString("transcoder.repo_path"));
|
this.repo = new Repository(this.config.getString("transcoder.repo_path"));
|
||||||
if (this.config.contains("transcoder.ffmpeg_path")) {
|
if (this.config.contains("transcoder.ffmpeg_path")) {
|
||||||
this.ffmpeg_path = this.config.getString("transcoder.ffmpeg_path");
|
this.ffmpeg_path = this.config.getString("transcoder.ffmpeg_path");
|
||||||
}
|
}
|
||||||
this.initDirectory();
|
this.repo.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a periodic timer task and start it
|
// create a periodic timer task and start it
|
||||||
public void start() {
|
public void run() throws IOException {
|
||||||
Timer timer = new Timer();
|
// pull list of files to transcode
|
||||||
timer.scheduleAtFixedRate(new RunTranscoderTask(this), 10000, this.config.getInt("transcoder.interval") * 60 * 1000);
|
File[] sourceFiles = this.repo.searchIngest();
|
||||||
}
|
|
||||||
|
|
||||||
// transcode files in the working directory
|
|
||||||
public void transcode() {
|
|
||||||
// search for files
|
|
||||||
System.out.println("Searching for files to transcode in " + this.repo_dir);
|
|
||||||
File repo = new File(Paths.get(this.repo_dir, "ingest").toString());
|
|
||||||
File[] sourceFiles = repo.listFiles();
|
|
||||||
|
|
||||||
|
// check if we have anything to process
|
||||||
if (sourceFiles.length == 0) {
|
if (sourceFiles.length == 0) {
|
||||||
System.out.println("There is nothing to transcode in " + this.repo_dir + "/ingest.");
|
Logger.logger.info("There is nothing in ingest, skipping transcode run.");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// transcode
|
// loop through each file
|
||||||
System.out.println("Transcoding files in " + this.repo_dir + "/ingest...");
|
for (File sf : sourceFiles) {
|
||||||
for (File f : sourceFiles) {
|
// check if the file is open before attempting to transcode it
|
||||||
String filePath = f.toString().substring(0, f.toString().lastIndexOf("."));
|
if (IOUtils.isFileLocked(sf)) {
|
||||||
String filename = Paths.get(filePath).getFileName().toString();
|
Logger.logger.info(String.format("Skipping %s because it is open in another program.", sf.toString()));
|
||||||
String outputPath = Paths.get(this.repo_dir, "output", String.format("%s.mov", filename)).toString();
|
continue;
|
||||||
|
|
||||||
String cmd = String.format("%s -i %s -y -f %s -c:v %s -vf %s -profile:v %s -c:a %s %s",
|
|
||||||
this.ffmpeg_path, // FFMPEG binary path
|
|
||||||
f.toString(), // input file
|
|
||||||
this.config.getString("transcoder.video_format"), // video container format
|
|
||||||
this.config.getString("transcoder.video_codec"), // video codec
|
|
||||||
this.config.getString("transcoder.video_parameters"), // video format
|
|
||||||
this.config.getString("transcoder.video_profile"), // video profile
|
|
||||||
this.config.getString("transcoder.audio_codec"), // audio codec
|
|
||||||
outputPath // output file path
|
|
||||||
);
|
|
||||||
|
|
||||||
ProcessBuilder pb = new ProcessBuilder(cmd.split("\\s+"));
|
|
||||||
pb.inheritIO(); // use the java processes' input and output streams
|
|
||||||
try {
|
|
||||||
Process process = pb.start();
|
|
||||||
int ret = process.waitFor();
|
|
||||||
System.out.printf("Program exited with code: %d\n", ret);
|
|
||||||
System.out.println(String.join(" ", pb.command()));
|
|
||||||
System.out.println();
|
|
||||||
} catch (IOException | InterruptedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// archive files
|
||||||
|
this.repo.archiveFile(sf);
|
||||||
|
// transcode files
|
||||||
|
this.transcodeFile(sf);
|
||||||
|
// cleanup old files
|
||||||
|
this.repo.cleanupFile(sf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// end output
|
// end output
|
||||||
System.out.println("------------ End of transcoding ------------");
|
Logger.logger.info("------------ End of transcoding ------------");
|
||||||
System.out.println();
|
Logger.logger.info("");
|
||||||
}
|
}
|
||||||
|
|
||||||
// copies sources files to the archive directory
|
// transcode files in the working directory
|
||||||
public void archive() {
|
public void transcodeFile(File sourceFile) throws IOException {
|
||||||
File repo = new File(Paths.get(this.repo_dir, "ingest").toString());
|
String filePath = sourceFile.toString().substring(0, sourceFile.toString().lastIndexOf("."));
|
||||||
File[] sourceFiles = repo.listFiles();
|
String filename = Paths.get(filePath).getFileName().toString();
|
||||||
|
String outputPath = Paths.get(this.repo.getOutputPath(), String.format("%s.mov", filename)).toString();
|
||||||
|
|
||||||
for (File f : sourceFiles) {
|
// build the custom video parameters string
|
||||||
Path filePath = Path.of(f.toString());
|
String videoParameters = String.format("scale=%s,fps=%s,format=%s",
|
||||||
String filename = filePath.getFileName().toString();
|
this.config.getString("transcoder.video_resolution"), // video resolution
|
||||||
String archivePath = Paths.get(this.repo_dir, "archive", filename).toString();
|
this.config.getString("transcoder.video_framerate"), // video frame rate
|
||||||
|
this.config.getString("transcoder.video_color") // video color format
|
||||||
|
);
|
||||||
|
|
||||||
try {
|
String cmd = String.format("%s -i INPUT_FILE -y -f %s -c:v %s -vf %s -profile:v %s -c:a %s OUTPUT_FILE",
|
||||||
Files.copy(filePath, Paths.get(archivePath), StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING);
|
this.ffmpeg_path, // FFMPEG binary path
|
||||||
} catch (IOException e) {
|
this.config.getString("transcoder.video_format"), // video container format
|
||||||
throw new RuntimeException(e);
|
this.config.getString("transcoder.video_codec"), // video codec
|
||||||
}
|
videoParameters, // custom video parameters
|
||||||
|
this.config.getString("transcoder.video_profile"), // video profile
|
||||||
|
this.config.getString("transcoder.audio_codec") // audio codec
|
||||||
|
);
|
||||||
|
|
||||||
|
String[] cmdArr = cmd.split("\\s+");
|
||||||
|
cmdArr[2] = sourceFile.toString();
|
||||||
|
cmdArr[cmdArr.length - 1] = outputPath;
|
||||||
|
System.out.println(String.join(" ", cmdArr));
|
||||||
|
|
||||||
|
ProcessBuilder pb = new ProcessBuilder(cmdArr);
|
||||||
|
pb.inheritIO(); // use the java processes' input and output streams
|
||||||
|
try {
|
||||||
|
Process process = pb.start();
|
||||||
|
int ret = process.waitFor();
|
||||||
|
Logger.logger.info(String.format("Program exited with code: %d", ret));
|
||||||
|
Logger.logger.info("");
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up the ingest directory once we're done
|
|
||||||
public void cleanup() {
|
|
||||||
File repo = new File(Paths.get(this.repo_dir, "ingest").toString());
|
|
||||||
File[] sourceFiles = repo.listFiles();
|
|
||||||
|
|
||||||
for (File f : sourceFiles) {
|
|
||||||
f.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ensures the transcoder's working directory is available
|
|
||||||
private void initDirectory() {
|
|
||||||
// create transcoder directory
|
|
||||||
IOUtils.createDirectory(this.repo_dir);
|
|
||||||
// create the sub-directories
|
|
||||||
IOUtils.createDirectory(Paths.get(this.repo_dir, "ingest").toString());
|
|
||||||
IOUtils.createDirectory(Paths.get(this.repo_dir, "archive").toString());
|
|
||||||
IOUtils.createDirectory(Paths.get(this.repo_dir, "output").toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
BIN
src/main/resources/icon.gif
Normal file
BIN
src/main/resources/icon.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
20
src/main/resources/log4j2.xml
Normal file
20
src/main/resources/log4j2.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Configuration status="info" name="Dragoon" packages="">
|
||||||
|
<Appenders>
|
||||||
|
<File name="DragoonLog" fileName="logs/dragoon.log">
|
||||||
|
<PatternLayout>
|
||||||
|
<Pattern>%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n</Pattern>
|
||||||
|
</PatternLayout>
|
||||||
|
</File>
|
||||||
|
<Console name="Console" target="SYSTEM_OUT">
|
||||||
|
<PatternLayout
|
||||||
|
pattern="%highlight{%d [%t] %-5level: %msg%n%throwable}" />
|
||||||
|
</Console>
|
||||||
|
</Appenders>
|
||||||
|
<Loggers>
|
||||||
|
<Root level="info">
|
||||||
|
<AppenderRef ref="DragoonLog"/>
|
||||||
|
<AppenderRef ref="Console"/>
|
||||||
|
</Root>
|
||||||
|
</Loggers>
|
||||||
|
</Configuration>
|
17
src/test/java/tech/bitgoblin/config/CmdTest.java
Normal file
17
src/test/java/tech/bitgoblin/config/CmdTest.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package tech.bitgoblin.config;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import org.apache.commons.cli.ParseException;
|
||||||
|
|
||||||
|
public class CmdTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldDefaultToHome() throws ParseException {
|
||||||
|
Cmd cmd = new Cmd(new String[]{});
|
||||||
|
assertTrue(cmd.getConfigPath().equals("~/.config/dragoon.toml"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,15 +1,20 @@
|
|||||||
package tech.bitgoblin.io;
|
package tech.bitgoblin.io;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.RandomAccessFile;
|
||||||
|
|
||||||
public class IOUtilsTest {
|
public class IOUtilsTest {
|
||||||
|
|
||||||
private static String testDir = "test-temp";
|
private static String testDir = "test-temp";
|
||||||
|
private static String testFile = "test.txt";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldCreateDirectory() {
|
public void shouldCreateDirectory() {
|
||||||
@ -28,9 +33,31 @@ public class IOUtilsTest {
|
|||||||
IOUtils.resolveTilda("~test");
|
IOUtils.resolveTilda("~test");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void fileShouldBeLocked() throws IOException {
|
||||||
|
RandomAccessFile raf = new RandomAccessFile(testFile, "rw");
|
||||||
|
assertTrue(IOUtils.isFileLocked(new File(testFile)));
|
||||||
|
raf.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void fileShouldNotBeLocked() throws IOException {
|
||||||
|
RandomAccessFile raf = new RandomAccessFile("test.txt", "rw");
|
||||||
|
raf.close();
|
||||||
|
assertFalse(IOUtils.isFileLocked(new File(testFile)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
// ensure that test files are created before running tests
|
||||||
|
public static void setup() throws IOException {
|
||||||
|
new File(testFile).createNewFile();
|
||||||
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
// ensure test files are cleaned up from the environment
|
||||||
public static void cleanup() {
|
public static void cleanup() {
|
||||||
new File(testDir).delete();
|
new File(testDir).delete();
|
||||||
|
new File(testFile).delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user