1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2025-07-06 07:44:57 +03:00

UNIX services write logs to stdout

To better adopt SoftEther VPN for execution in Docker container all
services output logs to stdout if running in foreground.
This commit is contained in:
Mikhail Pridushchenko
2017-06-28 16:22:53 +03:00
committed by Joshua Perry
parent 825931e11c
commit 02da8079ee
5 changed files with 331 additions and 237 deletions

View File

@ -133,6 +133,7 @@ BOOL kernel_status_inited = false; // Kernel state initialization flag
bool g_little_endian = true;
char *cmdline = NULL; // Command line
wchar_t *uni_cmdline = NULL; // Unicode command line
bool g_foreground = false; // Execute service in foreground mode
// Static variable
static char *exename = NULL; // EXE file name (ANSI)
@ -512,6 +513,7 @@ void InitMayaqua(bool memcheck, bool debug, int argc, char **argv)
// Fail this for some reason when this is called this in .NET mode
setbuf(stdout, NULL);
}
g_foreground = (argc >= 3 && StrCmpi(argv[2], UNIX_SVC_ARG_FOREGROUND) == 0);
// Acquisition whether NT
#ifdef OS_WIN32

View File

@ -395,6 +395,7 @@ extern char *cmdline;
extern wchar_t *uni_cmdline;
extern bool g_little_endian;
extern LOCK *tick_manual_lock;
extern bool g_foreground;
// Kernel state
#define NUM_KERNEL_STATUS 128

View File

@ -1703,6 +1703,23 @@ void *UnixFileOpen(char *name, bool write_mode, bool read_lock)
return (void *)p;
}
// Get UNIXIO object for stdout
void* GetUnixio4Stdout()
{
static UNIXIO unixio =
{
.fd = -1,
.write_mode = true
};
if (g_foreground)
{
unixio.fd = STDOUT_FILENO;
return &unixio;
}
return NULL;
}
// Return the current thread ID
UINT UnixThreadId()
{

View File

@ -179,6 +179,7 @@ void *UnixFileOpen(char *name, bool write_mode, bool read_lock);
void *UnixFileOpenW(wchar_t *name, bool write_mode, bool read_lock);
void *UnixFileCreate(char *name);
void *UnixFileCreateW(wchar_t *name);
void *GetUnixio4Stdout();
bool UnixFileWrite(void *pData, void *buf, UINT size);
bool UnixFileRead(void *pData, void *buf, UINT size);
void UnixFileClose(void *pData, bool no_flush);