Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
Merge branch 'dev' 75fda116
Browse files Browse the repository at this point in the history
  • Loading branch information
WindyCloudCute committed Nov 12, 2023
2 parents 65b7d37 + 16bea45 commit 4f6a909
Show file tree
Hide file tree
Showing 127 changed files with 6,690 additions and 1,171 deletions.
3 changes: 3 additions & 0 deletions .github/action-run-tests/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

echo "🎌 Running LRR Test Suite 🎌"

# Install cpan deps in case some are missing
perl ./tools/install.pl install-back

# Run the perl tests on the repo
prove -r -l -v tests/

15 changes: 15 additions & 0 deletions .github/workflows/push-brewtest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on: push
name: "Test Homebrew"
jobs:
testBrew:
name: 测试 Homebrew 版
runs-on: macos-latest
steps:
- uses: actions/checkout@master
- name: Build and test bundled homebrew formula
run: |
cd tools/build/homebrew
echo "Replacing commit hash in formula with current hash $(git rev-parse --verify HEAD)"
sed -i.bck "s/COMMIT_HASH/$(git rev-parse --verify HEAD)/" Lanraragi.rb
brew install --force --verbose --build-from-source Lanraragi.rb
brew test --verbose Lanraragi.rb
18 changes: 9 additions & 9 deletions .github/workflows/push-continous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
name: 构建并提交Docker镜像
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: actions/checkout@master
- name: 设置 QEMU
uses: docker/setup-qemu-action@master
uses: docker/setup-qemu-action@v2
- name: 设置 Docker Buildx
uses: docker/setup-buildx-action@master
- uses: actions/cache@main
uses: docker/setup-buildx-action@v2
- uses: actions/cache@v3
with:
path: /tmp/buildxcache
key: ${{ runner.os }}-docker-buildx-${{ github.sha }}
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
name: 为 Windows 构建构建并导出 Docker rootfs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: actions/checkout@master
- name: Docker 构建和导出
run: |
git submodule init
Expand All @@ -52,7 +52,7 @@ jobs:
docker create --name rootfs windycloud/lanraragi_cn:dev
docker export --output=package.tar rootfs
- name: 上传 rootfs
uses: actions/upload-artifact@main
uses: actions/upload-artifact@v1
with:
name: package
path: package.tar
Expand All @@ -62,9 +62,9 @@ jobs:
needs: exportDockerRootFS
runs-on: windows-latest
steps:
- uses: actions/checkout@main
- uses: actions/checkout@master
- name: 下载包
uses: actions/download-artifact@main
uses: actions/download-artifact@v1
with:
name: package
- name: 构建MSI安装程序
Expand All @@ -81,7 +81,7 @@ jobs:
choco install nuget.commandline
./tools/build/windows/build.ps1
- name: 上传安装程序
uses: actions/upload-artifact@main
uses: actions/upload-artifact@v1
with:
name: LANraragi.msi
path: ./tools/build/windows/Karen/Setup/bin/LANraragi.msi
4 changes: 2 additions & 2 deletions .github/workflows/push-continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ jobs:
name: 运行测试套件和 Perl Critic
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: actions/checkout@master
- name: 测试 Docker 构建
run: |
git submodule init
git submodule update
docker build -t windycloud/lanraragi_cn -f ./tools/build/docker/Dockerfile .
docker build -t windycloud/lanraragi_cn:dev -f ./tools/build/docker/Dockerfile .
- name: LANraragi测试套件
uses: ./.github/action-run-tests
- name: Perl Critic
Expand Down
50 changes: 16 additions & 34 deletions .github/workflows/release-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ jobs:
name: 构建和导出Windows构建的Docker rootfs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: actions/checkout@master
- name: Docker 构建和导出
run: |
git submodule init
git submodule update
docker build -t windycloud/lanraragi_cn -f ./tools/build/docker/Dockerfile-legacy .
docker build -t windycloud/lanraragi_cn -f ./tools/build/docker/Dockerfile --build-arg INSTALL_PARAMETER=-w .
docker create --name rootfs windycloud/lanraragi_cn
docker export --output=package.tar rootfs
- name: 上传 rootfs
uses: actions/upload-artifact@main
uses: actions/upload-artifact@v1
with:
name: package
path: package.tar
Expand All @@ -27,9 +27,9 @@ jobs:
needs: exportDockerRootFS
runs-on: windows-latest
steps:
- uses: actions/checkout@main
- uses: actions/checkout@master
- name: 下载包
uses: actions/download-artifact@main
uses: actions/download-artifact@v1
with:
name: package
- name: 构建MSI安装程序
Expand All @@ -46,7 +46,7 @@ jobs:
choco install nuget.commandline
./tools/build/windows/build.ps1
- name: 上传安装程序
uses: actions/upload-artifact@main
uses: actions/upload-artifact@v1
with:
name: wsl
path: ./tools/build/windows/Karen/Setup/bin/LANraragi.msi
Expand All @@ -57,7 +57,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 下载包
uses: actions/download-artifact@main
uses: actions/download-artifact@v1
with:
name: wsl
- name: 上传安装程序以发布
Expand All @@ -76,12 +76,12 @@ jobs:
name: 构建最新的Docker图像
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: actions/checkout@master
- name: 设置 QEMU
uses: docker/setup-qemu-action@master
uses: docker/setup-qemu-action@v2
- name: 设置 Docker Buildx
uses: docker/setup-buildx-action@master
- uses: actions/cache@main
uses: docker/setup-buildx-action@v2
- uses: actions/cache@v3
with:
path: /tmp/buildxcache
key: ${{ runner.os }}-docker-buildx-${{ github.sha }}
Expand All @@ -106,26 +106,8 @@ jobs:
--cache-from "type=local,src=/tmp/buildxcache" \
--cache-to "type=local,dest=/tmp/buildxcache" \
--file ./tools/build/docker/Dockerfile .
# - uses: Ilshidur/action-discord@master
# env:
# DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
# with:
# args: 'Docker image built and available on Docker Hub! 🐳'

# discordNotifications:
# name: 发布一些通知
# runs-on: ubuntu-latest
# env:
# DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
# steps:
# - name: 从 GITHUB_REF 中提取版本号
# run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
# - uses: Ilshidur/action-discord@master
# with:
# args: 'LANraragi {{ RELEASE_VERSION }} is now available! @everyone'
# - uses: Ilshidur/action-discord@master
# with:
# args: 'https://github.com/WindyCloudCute/LANraragi_Chinese/releases/tag/{{ RELEASE_VERSION }}'
# - uses: Ilshidur/action-discord@master
# with:
# args: 'Docker image and Windows installer are building... Please wait warmly. ☕'
- uses: Ilshidur/action-discord@master
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
with:
args: 'Docker image built and available on Docker Hub! 🐳'
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ content
.minion.db*
npm-debug.log
dump.rdb
package-lock.json
.vstags
.gitbook
*qemu-*-static*
Dockerfile.*
.DS_Store
config.log
autobackup.json
lib/LANraragi/Plugin/Metadata/ETagCN.pm
lib/LANraragi/Plugin/Scripts/ETagConverter.pm
lib/LANraragi/Plugin/Metadata/ETagCN.pm
Makefile
oshino
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[submodule "tools/build/windows/Karen"]
path = tools/build/windows/Karen
url = https://github.com/WindyCloudCute/Karen
[submodule "customize/ETagCN"]
path = customize/ETagCN
url = https://github.com/zhy201810576/ETagCN
[submodule "customize/ETagConverter"]
path = customize/ETagConverter
url = https://github.com/zhy201810576/ETagConverter
[submodule "customize/ETagCN"]
path = customize/ETagCN
url = https://github.com/zhy201810576/ETagCN
62 changes: 36 additions & 26 deletions lib/LANraragi.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use Storable;
use Sys::Hostname;
use Config;

use LANraragi::Utils::Generic qw(start_shinobu start_minion);
use LANraragi::Utils::Logging qw(get_logger get_logdir);
use LANraragi::Utils::Plugins qw(get_plugins);
use LANraragi::Utils::Generic qw(start_shinobu start_minion);
use LANraragi::Utils::Logging qw(get_logger get_logdir);
use LANraragi::Utils::Plugins qw(get_plugins);
use LANraragi::Utils::TempFolder qw(get_temp);
use LANraragi::Utils::Routing;
use LANraragi::Utils::Minion;
Expand All @@ -36,8 +36,19 @@ sub startup {
my $vername = $packagejson->{version_name};
my $descstr = $packagejson->{description};

# Use the hostname and osname for a sorta-unique set of secrets.
$self->secrets( [ hostname(), $Config{"osname"}, 'oshino' ] );
my $secret = "";
my $secretfile_path = get_temp . "/oshino";
if ( -e $secretfile_path ) {
$secret = Mojo::File->new($secretfile_path)->slurp;
} else {

# Generate a random string as the secret and store it in a file
$secret .= sprintf( "%x", rand 16 ) for 1 .. 8;
Mojo::File->new($secretfile_path)->spew($secret);
}

# Use the hostname alongside the random secret
$self->secrets( [ $secret . hostname() ] );
$self->plugin('RenderFile');

# Set Template::Toolkit as default renderer so we can use the LRR templates
Expand Down Expand Up @@ -72,19 +83,11 @@ sub startup {
die;
}

# Check old settings and migrate them if needed
if ( $self->LRR_CONF->get_redis->keys('LRR_*') ) {
say "将旧的设置迁移到新的格式...";
migrate_old_settings($self);
}

my $devmode;

# Catch Redis errors on our first connection. This is useful in case of temporary LOADING errors,
# Where Redis lets us send commands but doesn't necessarily reply to them properly.
# (https://github.com/redis/redis/issues/4624)
while (1) {
eval { $devmode = $self->LRR_CONF->enable_devmode; };
eval { $self->LRR_CONF->get_redis->keys('*') };

last unless ($@);

Expand All @@ -93,13 +96,13 @@ sub startup {
sleep 2;
}

# Enable AOF saving on the Redis server.
# This allows us to start creating an aof file using existing RDB snapshot data.
# Later LRR releases will then be able to set appendonly directly in redis.conf without fearing data loss.
say "在 Redis 上启用 AOF...这可能需要一段时间。";
$self->LRR_CONF->get_redis->config_set( "appendonly", "yes" );
# Check old settings and migrate them if needed
if ( $self->LRR_CONF->get_redis->keys('LRR_*') ) {
say "Migrating old settings to new format...";
migrate_old_settings($self);
}

if ($devmode) {
if ( $self->LRR_CONF->enable_devmode ) {
$self->mode('development');
$self->LRR_LOGGER->info("LANraragi $version (重新)启动。(调试模式)");

Expand All @@ -113,7 +116,9 @@ sub startup {
open( my $fh, '>>', $logpath )
or die "无法打开文件 '$logpath' $!";

# print $fh "[Mojolicious] " . $lines[0] . " " . $lines[1] . "\n";
my $l1 = $lines[0] // "";
my $l2 = $lines[1] // "";
print $fh "[Mojolicious] $l1 $l2 \n";
close $fh;
}
);
Expand Down Expand Up @@ -145,10 +150,15 @@ sub startup {
# Enable Minion capabilities in the app
shutdown_from_pid( get_temp . "/minion.pid" );

my $miniondb = $self->LRR_CONF->get_redisad . "/" . $self->LRR_CONF->get_miniondb;
say "Minion将使用位于 $miniondb 的Redis数据库";
$self->plugin( 'Minion' => { Redis => "redis://$miniondb" } );
$self->LRR_LOGGER->info("成功连接到Minion数据库。");
my $miniondb = $self->LRR_CONF->get_redisad . "/" . $self->LRR_CONF->get_miniondb;
my $redispassword = $self->LRR_CONF->get_redispassword;

# If the password is non-empty, add the required delimiters
if ($redispassword) { $redispassword = "x:" . $redispassword . "@"; }

say "Minion will use the Redis database at $miniondb";
$self->plugin( 'Minion' => { Redis => "redis://$redispassword$miniondb" } );
$self->LRR_LOGGER->info("Successfully connected to Minion database.");
$self->minion->missing_after(5); # Clean up older workers after 5 seconds of unavailability

LANraragi::Utils::Minion::add_tasks( $self->minion );
Expand Down Expand Up @@ -201,7 +211,7 @@ sub add_sigint_handler {
shutdown_from_pid( get_temp . "/minion.pid" );

\&$old_int; # Calling the old handler to cleanly exit the server
}
}
}

sub migrate_old_settings {
Expand Down
Loading

0 comments on commit 4f6a909

Please sign in to comment.