1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-29 04:23:51 +00:00

Allow specification of port through env variable.

This commit is contained in:
Bartosz Taudul 2020-03-08 16:14:36 +01:00
parent 2671245d41
commit c6bb08355c
2 changed files with 10 additions and 2 deletions

View File

@ -1033,6 +1033,7 @@ Profiler::Profiler()
, m_sock( nullptr )
, m_broadcast( nullptr )
, m_noExit( false )
, m_userPort( 0 )
, m_zoneId( 1 )
, m_samplingPeriod( 0 )
, m_stream( LZ4_createStream() )
@ -1076,6 +1077,12 @@ Profiler::Profiler()
}
#endif
const char* userPort = getenv( "TRACY_PORT" );
if( userPort )
{
m_userPort = atoi( userPort );
}
s_thread = (Thread*)tracy_malloc( sizeof( Thread ) );
new(s_thread) Thread( LaunchWorker, this );
@ -1169,9 +1176,9 @@ void Profiler::Worker()
SetThreadName( "Tracy Profiler" );
#ifdef TRACY_DATA_PORT
const auto dataPort = TRACY_DATA_PORT;
const auto dataPort = m_userPort != 0 ? m_userPort : TRACY_DATA_PORT;
#else
const auto dataPort = 8086;
const auto dataPort = m_userPort != 0 ? m_userPort : 8086;
#endif
#ifdef TRACY_BROADCAST_PORT
const auto broadcastPort = TRACY_BROADCAST_PORT;

View File

@ -619,6 +619,7 @@ private:
Socket* m_sock;
UdpBroadcast* m_broadcast;
bool m_noExit;
uint32_t m_userPort;
std::atomic<uint32_t> m_zoneId;
int64_t m_samplingPeriod;