-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #490 from MUnique/dev/restart-game-servers-adminpanel
Restart game servers through admin panel
- Loading branch information
Showing
10 changed files
with
184 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// <copyright file="ServerRestarter.cs" company="MUnique"> | ||
// Licensed under the MIT License. See LICENSE file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace MUnique.OpenMU.AdminPanel.Host; | ||
|
||
using MUnique.OpenMU.Interfaces; | ||
|
||
/// <summary> | ||
/// An implementation of <see cref="ISupportServerRestart"/>. | ||
/// It restarts the server by stopping and starting it. | ||
/// </summary> | ||
public class ServerRestarter : ISupportServerRestart | ||
{ | ||
private readonly IServerProvider _serverProvider; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ServerRestarter"/> class. | ||
/// </summary> | ||
/// <param name="serverProvider">The server provider.</param> | ||
public ServerRestarter(IServerProvider serverProvider) | ||
{ | ||
this._serverProvider = serverProvider; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public async ValueTask RestartAllAsync(bool onDatabaseInit) | ||
{ | ||
var gameServers = this._serverProvider.Servers.Where(server => server.Type == ServerType.GameServer).ToList(); | ||
foreach (var gameServer in gameServers) | ||
{ | ||
await gameServer.ShutdownAsync().ConfigureAwait(false); | ||
// It's started again automatically by the docker host. | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// <copyright file="ISupportServerRestart.cs" company="MUnique"> | ||
// Licensed under the MIT License. See LICENSE file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace MUnique.OpenMU.Interfaces; | ||
|
||
/// <summary> | ||
/// Interface for a class which supports to restart a server. | ||
/// </summary> | ||
public interface ISupportServerRestart | ||
{ | ||
/// <summary> | ||
/// Restarts all servers of this container. | ||
/// </summary> | ||
/// <param name="onDatabaseInit">If set to <c>true</c>, this method is called during a database initialization.</param> | ||
/// <returns></returns> | ||
Check warning on line 16 in src/Interfaces/ISupportServerRestart.cs GitHub Actions / build
|
||
ValueTask RestartAllAsync(bool onDatabaseInit); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters