File tree Expand file tree Collapse file tree 4 files changed +83
-8
lines changed
Serein.Cli/Services/Interaction
Serein.Core/Services/Servers Expand file tree Collapse file tree 4 files changed +83
-8
lines changed Original file line number Diff line number Diff line change
1
+ on :
2
+ push :
3
+ paths :
4
+ - ' Dockerfile'
5
+ - ' **/*.cs'
6
+ - ' **/*.csproj'
7
+
8
+ workflow_dispatch :
9
+
10
+ jobs :
11
+ push :
12
+ runs-on : ubuntu-latest
13
+ steps :
14
+ - uses : actions/checkout@v4
15
+
16
+ - name : Set up QEMU
17
+ uses : docker/setup-qemu-action@v3
18
+
19
+ - name : Set up Docker Buildx
20
+ uses : docker/setup-buildx-action@v3
21
+
22
+ - name : Login to Github Registry
23
+ uses : docker/login-action@v3
24
+ if : github.event_name != 'pull_request'
25
+ with :
26
+ registry : ghcr.io
27
+ username : ${{ github.repository_owner }}
28
+ password : ${{ secrets.GH_TOKEN }}
29
+
30
+ - name : Extract metadata (tags, labels) for Docker
31
+ id : meta
32
+ uses : docker/metadata-action@v5
33
+ with :
34
+ images : |
35
+ ghcr.io/${{ github.repository_owner }}/serein.cli
36
+ tags : |
37
+ type=edge
38
+ type=sha,event=branch
39
+ type=ref,event=tag
40
+
41
+ - name : Build and push
42
+ uses : docker/build-push-action@v5
43
+ with :
44
+ context : .
45
+ file : " Dockerfile"
46
+ push : ${{ github.event_name != 'pull_request' }}
47
+ tags : ${{ steps.meta.outputs.tags }}
48
+ labels : ${{ steps.meta.outputs.labels }}
49
+ platforms : linux/amd64, linux/arm64, linux/arm
Original file line number Diff line number Diff line change
1
+ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
2
+
3
+ WORKDIR /src
4
+ COPY . .
5
+
6
+ ARG TARGETARCH
7
+ RUN dotnet publish src/Serein.Cli -a $TARGETARCH -c Release -o /app/bin
8
+
9
+ WORKDIR /app/bin
10
+ ENV DOTNET_EnableWriteXorExecute=0
11
+
12
+ RUN echo "#!/bin/sh \r\n /app/bin/Serein.Cli" > /app/bin/serein-entrypoint.sh
13
+ RUN chmod +x /app/bin/serein-entrypoint.sh
14
+
15
+ ENTRYPOINT [ "/app/bin/serein-entrypoint.sh" ]
Original file line number Diff line number Diff line change @@ -81,11 +81,22 @@ out var server
81
81
Console . CancelKeyPress -= IgnoreCtrlC ;
82
82
flag = false ;
83
83
}
84
- var response = prompt . ReadLineAsync ( ) . Await ( ) ;
85
84
86
- if ( response . IsSuccess )
85
+ try
87
86
{
88
- ProcessInput ( response . Text ) ;
87
+ var response = prompt . ReadLineAsync ( ) . Await ( ) ;
88
+
89
+ if ( response . IsSuccess )
90
+ {
91
+ ProcessInput ( response . Text ) ;
92
+ }
93
+ }
94
+ catch ( Exception e )
95
+ {
96
+ _logger . LogError (
97
+ e ,
98
+ "读取输入时发生错误。若此错误持续出现,请尝试关闭彩色输出"
99
+ ) ;
89
100
}
90
101
}
91
102
}
Original file line number Diff line number Diff line change @@ -70,11 +70,11 @@ ReactionTrigger reactionManager
70
70
_commandHistory = [ ] ;
71
71
_cache = [ ] ;
72
72
_updateTimer = new ( 2000 ) { AutoReset = true } ;
73
- _updateTimer . Elapsed += ( _ , _ ) => UpdateInfo ( ) ;
73
+ _updateTimer . Elapsed += ( _ , _ ) => Task . Run ( UpdateInfo ) ;
74
74
_info = new ( ) ;
75
75
PluginManager = new ( this ) ;
76
76
77
- ServerStatusChanged += ( _ , _ ) => UpdateInfo ( ) ;
77
+ ServerStatusChanged += ( _ , _ ) => Task . Run ( UpdateInfo ) ;
78
78
}
79
79
80
80
protected abstract void StartProcess ( ) ;
@@ -441,7 +441,7 @@ private void WaitAndRestart()
441
441
) ;
442
442
}
443
443
444
- private async Task UpdateInfo ( )
444
+ private void UpdateInfo ( )
445
445
{
446
446
if ( ! Status && _process is null )
447
447
{
@@ -454,7 +454,7 @@ private async Task UpdateInfo()
454
454
_info . CpuUsage = 0 ;
455
455
return ;
456
456
}
457
- else if ( _process is null )
457
+ else if ( _process is null || _process . HasExited )
458
458
{
459
459
return ;
460
460
}
@@ -469,7 +469,7 @@ private async Task UpdateInfo()
469
469
470
470
if ( Configuration . PortIPv4 >= 0 )
471
471
{
472
- await Task . Run ( ( ) => _info . Stat = new ( "127.0.0.1" , ( ushort ) Configuration . PortIPv4 ) ) ;
472
+ _info . Stat = new ( "127.0.0.1" , ( ushort ) Configuration . PortIPv4 ) ;
473
473
}
474
474
}
475
475
}
You can’t perform that action at this time.
0 commit comments