Find a random port number to use for the application server to avoid conflicts

with any other apps that may have already bound to the default port used by CP.
This commit is contained in:
Dave Page
2013-10-04 17:12:10 +01:00
parent a1524f3726
commit 457a842cec
7 changed files with 64 additions and 38 deletions

View File

@@ -22,8 +22,11 @@
// App headers
#include "Server.h"
Server::Server()
Server::Server(quint16 port)
{
// Appserver port
m_port = port;
// Initialise Python
Py_SetProgramName(PGA_APP_NAME.toUtf8().data());
Py_Initialize();
@@ -74,6 +77,9 @@ void Server::run()
return;
}
// Set the port number
PyRun_SimpleString(QString("PGADMIN_PORT = %1").arg(m_port).toLatin1());
if (PyRun_SimpleFile(cp, m_appfile.toUtf8().data()) != 0)
setError("Failed to launch the application server, server thread exiting.");