diff --git a/buildWinX64SelfContainedRelease.bat b/buildWinX64SelfContainedRelease.bat index 8079f0f0..f9524e18 100644 --- a/buildWinX64SelfContainedRelease.bat +++ b/buildWinX64SelfContainedRelease.bat @@ -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 \ No newline at end of file diff --git a/devdocs/tools.txt b/devdocs/tools.txt index affabbd3..c5accf35 100644 --- a/devdocs/tools.txt +++ b/devdocs/tools.txt @@ -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 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- diff --git a/dist/win-x64/start.bat b/dist/win-x64/start.bat index bf313d37..26c03e42 100644 --- a/dist/win-x64/start.bat +++ b/dist/win-x64/start.bat @@ -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 -start "" http://localhost:7575/api/v8/ \ No newline at end of file +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 \ No newline at end of file diff --git a/server/AyaNova/Controllers/ServerStateController.cs b/server/AyaNova/Controllers/ServerStateController.cs index b25be837..63c062fc 100644 --- a/server/AyaNova/Controllers/ServerStateController.cs +++ b/server/AyaNova/Controllers/ServerStateController.cs @@ -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 log; private readonly ApiServerState serverState; + private readonly IHostApplicationLifetime _appLifetime; /// /// ctor @@ -33,11 +35,12 @@ namespace AyaNova.Api.Controllers /// /// /// - public ServerStateController(ILogger logger, ApiServerState apiServerState, AyContext dbcontext) + public ServerStateController(ILogger 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; } } + + + /// + /// Shut down server completely + /// + /// Accepted + [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(); + + } //------------ diff --git a/server/AyaNova/Startup.cs b/server/AyaNova/Startup.cs index 0b49a5b4..f7e566af 100644 --- a/server/AyaNova/Startup.cs +++ b/server/AyaNova/Startup.cs @@ -34,7 +34,7 @@ namespace AyaNova { var nlogLoggerProvider = new NLogLoggerProvider(); _newLog = nlogLoggerProvider.CreateLogger("SERVER"); - _hostingEnvironment = hostingEnvironment; + _hostingEnvironment = hostingEnvironment; AyaNova.Util.ApplicationLogging.LoggerProvider = nlogLoggerProvider; ServerBootConfig.AYANOVA_CONTENT_ROOT_PATH = hostingEnvironment.ContentRootPath; } @@ -43,6 +43,8 @@ namespace AyaNova private string _connectionString = ""; private readonly Microsoft.AspNetCore.Hosting.IWebHostEnvironment _hostingEnvironment; + + //////////////////////////////////////////////////////////// // //