Skip to content

Commit

Permalink
Added possibility to run server on custom port
Browse files Browse the repository at this point in the history
  • Loading branch information
stumpdk committed May 30, 2016
1 parent 57a0b8c commit c47d22e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Library/MySqlServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class MySqlServer
private string _dataDirectory;
private string _dataRootDirectory;

private int _serverPort = 3306;

private Process _process;

private MySqlConnection _testConnection;
Expand Down Expand Up @@ -162,11 +164,12 @@ public void StartServer()
{
"--standalone",
"--console",
string.Format("--basedir=" + "\"{0}\"",_mysqlDirectory),
string.Format("--lc-messages-dir=" + "\"{0}\"",_mysqlDirectory),
string.Format("--datadir=" + "\"{0}\"",_dataDirectory),
string.Format("--basedir=\"{0}\"",_mysqlDirectory),
string.Format("--lc-messages-dir=\"{0}\"",_mysqlDirectory),
string.Format("--datadir=\"{0}\"",_dataDirectory),
"--skip-grant-tables",
"--enable-named-pipe",
string.Format("--port={0}", _serverPort.ToString()),
// "--skip-networking",
"--innodb_fast_shutdown=2",
"--innodb_doublewrite=OFF",
Expand All @@ -191,6 +194,16 @@ public void StartServer()
this.waitForStartup();
}

/// <summary>
/// Start the server on a specified port number
/// </summary>
/// <param name="serverPort">The port on which the server should listen</param>
public void StartServer(int serverPort)
{
_serverPort = serverPort;
StartServer();
}

/// <summary>
/// Checks if the server is started. The most reliable way is simply to check if we can connect to it
/// </summary>
Expand Down

0 comments on commit c47d22e

Please sign in to comment.