This commit is contained in:
2020-08-11 23:04:00 +00:00
parent 5e41a8360c
commit 655fb642c7
5 changed files with 41 additions and 9 deletions

View File

@@ -1,8 +1,8 @@
@echo **************************************************************
@echo ******************** BUILD SERVER ****************************
@echo **************************************************************
rmdir C:\data\code\raven\dist\win-x64\files /s
mkdir C:\data\code\raven\dist\win-x64\files
rmdir C:\data\code\raven\dist\win-x64\ayanova /s
mkdir C:\data\code\raven\dist\win-x64\ayanova
cd C:\data\code\raven\server\AyaNova\
dotnet publish -c Release -o C:\data\code\raven\dist\win-x64\files\ -r win-x64
dotnet publish -c Release -o C:\data\code\raven\dist\win-x64\ayanova\ -r win-x64
pause

View File

@@ -510,6 +510,9 @@ ICON GENERATOR
POSTGRES SQL PORTABLE:
https://github.com/rsubr/postgresql-portable/releases/tag/v12.1
Also this:
https://www.postgresonline.com/journal/archives/172-Starting-PostgreSQL-in-windows-without-install.html
DOCKER POSTGRES DEVELOPMENT STATION COMMANDS AND USEFUL INFO
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

View File

@@ -1,5 +1,8 @@
rem start "AyaNova Server" /MAX ayanova.exe --AYANOVA_DB_CONNECTION="Server=localhost;Username=postgres;Password=mypasswordforpostgres;Database=AyaNova;" --AYANOVA_DEFAULT_TRANSLATION="en" --AYANOVA_USE_URLS="http://*:7575;" --AYANOVA_BACKUP_PG_DUMP_PATH="..\PostgreSQLPortable\App\PgSQL\bin\" --AYANOVA_FOLDER_USER_FILES= "..\data\userfiles" --AYANOVA_FOLDER_BACKUP_FILES="..\data\backupfiles"
setlocal
set AYANOVA_DB_CONNECTION="Server=localhost;Username=postgres;Password=mypasswordforpostgres;Database=AyaNova;"
start "PostgreSQLServer" /MAX .\PostgreSQLPortable_12.1\PostgreSQLPortable.exe
cd .\files
start "AyaNova Server" /MAX ayanova.exe --AYANOVA_DB_CONNECTION="Server=localhost;Username=postgres;Password=mypasswordforpostgres;Database=AyaNova;" --AYANOVA_DEFAULT_TRANSLATION="en" --AYANOVA_USE_URLS="http://*:7575;" --AYANOVA_BACKUP_PG_DUMP_PATH=".\PostgreSQLPortable\App\PgSQL\bin\" --AYANOVA_FOLDER_USER_FILES= ".\data\userfiles" --AYANOVA_FOLDER_BACKUP_FILES=".\data\backupfiles"
timeout 10
cd .\ayanova
start "AyaNova Server" /MAX ayanova.exe --AYANOVA_DEFAULT_TRANSLATION="en" --AYANOVA_USE_URLS="http://*:7575;" --AYANOVA_BACKUP_PG_DUMP_PATH="..\PostgreSQLPortable\App\PgSQL\bin\" --AYANOVA_FOLDER_USER_FILES= "..\data\userfiles" --AYANOVA_FOLDER_BACKUP_FILES="..\data\backupfiles"
start "" http://localhost:7575/api/v8/
endlocal

View File

@@ -8,6 +8,7 @@ using AyaNova.Api.ControllerHelpers;
using AyaNova.Biz;
using AyaNova.Models;
using System.ComponentModel.DataAnnotations;
using Microsoft.Extensions.Hosting;
namespace AyaNova.Api.Controllers
@@ -26,6 +27,7 @@ namespace AyaNova.Api.Controllers
private readonly AyContext ct;
private readonly ILogger<ServerStateController> log;
private readonly ApiServerState serverState;
private readonly IHostApplicationLifetime _appLifetime;
/// <summary>
/// ctor
@@ -33,11 +35,12 @@ namespace AyaNova.Api.Controllers
/// <param name="logger"></param>
/// <param name="apiServerState"></param>
/// <param name="dbcontext"></param>
public ServerStateController(ILogger<ServerStateController> logger, ApiServerState apiServerState, AyContext dbcontext)
public ServerStateController(ILogger<ServerStateController> logger, ApiServerState apiServerState, AyContext dbcontext, IHostApplicationLifetime appLifetime)
{
ct = dbcontext;
log = logger;
serverState = apiServerState;
_appLifetime = appLifetime;
}
@@ -111,6 +114,27 @@ namespace AyaNova.Api.Controllers
public string Reason { get; set; }
}
/// <summary>
/// Shut down server completely
/// </summary>
/// <returns>Accepted</returns>
[HttpPost("shutdown")]
public ActionResult PostShutdown()
{
if (serverState.IsClosed)//no state change allowed when closed
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.ServerState))
return StatusCode(403, new ApiNotAuthorizedResponse());
log.LogInformation($"Server shut down requested by user {UserNameFromContext.Name(HttpContext.Items)}, server shutting down now...");
_appLifetime.StopApplication();
return Accepted();
}
//------------

View File

@@ -43,6 +43,8 @@ namespace AyaNova
private string _connectionString = "";
private readonly Microsoft.AspNetCore.Hosting.IWebHostEnvironment _hostingEnvironment;
////////////////////////////////////////////////////////////
//
//