提交 8916803d authored 作者: Thomas Mueller's avatar Thomas Mueller

Servers can now be started as a daemon thread.

上级 244beedf
...@@ -3,7 +3,7 @@ org.h2.tools.Backup.main=Options are case sensitive. Supported options are\:\n[- ...@@ -3,7 +3,7 @@ org.h2.tools.Backup.main=Options are case sensitive. Supported options are\:\n[-
org.h2.tools.ChangeFileEncryption=Allows changing the database file encryption password or algorithm.\nThis tool can not be used to change a password of a user.\n The database must be closed before using this tool. org.h2.tools.ChangeFileEncryption=Allows changing the database file encryption password or algorithm.\nThis tool can not be used to change a password of a user.\n The database must be closed before using this tool.
org.h2.tools.ChangeFileEncryption.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-cipher type] The encryption type (AES or XTEA)\n[-dir <dir>] The database directory (default\: .)\n[-db <database>] Database name (all databases if not set)\n[-decrypt <pwd>] The decryption password (if not set\: not yet encrypted)\n[-encrypt <pwd>] The encryption password (if not set\: do not encrypt)\n[-quiet] Do not print progress information org.h2.tools.ChangeFileEncryption.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-cipher type] The encryption type (AES or XTEA)\n[-dir <dir>] The database directory (default\: .)\n[-db <database>] Database name (all databases if not set)\n[-decrypt <pwd>] The decryption password (if not set\: not yet encrypted)\n[-encrypt <pwd>] The encryption password (if not set\: do not encrypt)\n[-quiet] Do not print progress information
org.h2.tools.Console=Starts the H2 Console (web-) server, as well as the TCP and PG server. org.h2.tools.Console=Starts the H2 Console (web-) server, as well as the TCP and PG server.
org.h2.tools.Console.main=When running without options, -tcp, -web, -browser and -pg are started.\nOptions are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-web] Start the web server with the H2 Console\n[-tool] Start the icon or window that allows to start a browser\n[-browser] Start a browser and open a page to connect to the web server\n[-tcp] Start the TCP server\n[-pg] Start the PG server\nFor each Server, additional options are available;\n for details, see the Server tool.\nIf a service can not be started, the program\n terminates with an exit code of 1. org.h2.tools.Console.main=When running without options, -tcp, -web, -browser and -pg are started.\nOptions are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-web] Start the web server with the H2 Console\n[-tool] Start the icon or window that allows to start a browser\n[-browser] Start a browser connecting to the web server\n[-tcp] Start the TCP server\n[-pg] Start the PG server\nFor each Server, additional options are available;\n for details, see the Server tool.\nIf a service can not be started, the program\n terminates with an exit code of 1.
org.h2.tools.ConvertTraceFile=Converts a .trace.db file to a SQL script and Java source code.\nSQL statement statistics are listed as well. org.h2.tools.ConvertTraceFile=Converts a .trace.db file to a SQL script and Java source code.\nSQL statement statistics are listed as well.
org.h2.tools.ConvertTraceFile.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-traceFile <file>] The trace file name (default\: test.trace.db)\n[-script <file>] The script file name (default\: test.sql)\n[-javaClass <file>] The Java directory and class file name (default\: Test) org.h2.tools.ConvertTraceFile.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-traceFile <file>] The trace file name (default\: test.trace.db)\n[-script <file>] The script file name (default\: test.sql)\n[-javaClass <file>] The Java directory and class file name (default\: Test)
org.h2.tools.CreateCluster=Creates a cluster from a standalone database.\nCopies a database to another location if required. org.h2.tools.CreateCluster=Creates a cluster from a standalone database.\nCopies a database to another location if required.
...@@ -19,6 +19,6 @@ org.h2.tools.RunScript.main=Options are case sensitive. Supported options are\:\ ...@@ -19,6 +19,6 @@ org.h2.tools.RunScript.main=Options are case sensitive. Supported options are\:\
org.h2.tools.Script=Creates a SQL script file by extracting the schema and data of a database. org.h2.tools.Script=Creates a SQL script file by extracting the schema and data of a database.
org.h2.tools.Script.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-url "<url>"] The database URL (jdbc\:...)\n[-user <user>] The user name (default\: sa)\n[-password <pwd>] The password\n[-script <file>] The target script file name (default\: backup.sql)\n[-options ...] A list of options (only for embedded H2, see RUNSCRIPT)\n[-quiet] Do not print progress information org.h2.tools.Script.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-url "<url>"] The database URL (jdbc\:...)\n[-user <user>] The user name (default\: sa)\n[-password <pwd>] The password\n[-script <file>] The target script file name (default\: backup.sql)\n[-options ...] A list of options (only for embedded H2, see RUNSCRIPT)\n[-quiet] Do not print progress information
org.h2.tools.Server=Starts the H2 Console (web-) server, TCP, and PG server. org.h2.tools.Server=Starts the H2 Console (web-) server, TCP, and PG server.
org.h2.tools.Server.main=When running without options, -tcp, -web, -browser and -pg are started.\nOptions are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-web] Start the web server with the H2 Console\n[-webAllowOthers] Allow other computers to connect - see below\n[-webPort <port>] The port (default\: 8082)\n[-webSSL] Use encrypted (HTTPS) connections\n[-browser] Start a browser and open a page to connect to the web server\n[-tcp] Start the TCP server\n[-tcpAllowOthers] Allow other computers to connect - see below\n[-tcpPort <port>] The port (default\: 9092)\n[-tcpSSL] Use encrypted (SSL) connections\n[-tcpPassword <pwd>] The password for shutting down a TCP server\n[-tcpShutdown "<url>"] Stop the TCP server; example\: tcp\://localhost\:9094\n[-tcpShutdownForce] Do not wait until all connections are closed\n[-pg] Start the PG server\n[-pgAllowOthers] Allow other computers to connect - see below\n[-pgPort <port>] The port (default\: 5435)\n[-baseDir <dir>] The base directory for H2 databases; for all servers\n[-ifExists] Only existing databases may be opened; for all servers\n[-trace] Print additional trace information; for all servers\nThe options -xAllowOthers are potentially risky.\nFor details, see Advanced Topics / Protection against Remote Access. org.h2.tools.Server.main=When running without options, -tcp, -web, -browser and -pg are started.\nOptions are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-web] Start the web server with the H2 Console\n[-webAllowOthers] Allow other computers to connect - see below\n[-webDaemon] Use a daemon thread\n[-webPort <port>] The port (default\: 8082)\n[-webSSL] Use encrypted (HTTPS) connections\n[-browser] Start a browser connecting to the web server\n[-tcp] Start the TCP server\n[-tcpAllowOthers] Allow other computers to connect - see below\n[-tcpDaemon] Use a daemon thread\n[-tcpPort <port>] The port (default\: 9092)\n[-tcpSSL] Use encrypted (SSL) connections\n[-tcpPassword <pwd>] The password for shutting down a TCP server\n[-tcpShutdown "<url>"] Stop the TCP server; example\: tcp\://localhost\n[-tcpShutdownForce] Do not wait until all connections are closed\n[-pg] Start the PG server\n[-pgAllowOthers] Allow other computers to connect - see below\n[-pgDaemon] Use a daemon thread\n[-pgPort <port>] The port (default\: 5435)\n[-baseDir <dir>] The base directory for H2 databases (all servers)\n[-ifExists] Only existing databases may be opened (all servers)\n[-trace] Print additional trace information (all servers)\nThe options -xAllowOthers are potentially risky.\nFor details, see Advanced Topics / Protection against Remote Access.
org.h2.tools.Shell=Interactive command line tool to access a database using JDBC. org.h2.tools.Shell=Interactive command line tool to access a database using JDBC.
org.h2.tools.Shell.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-url "<url>"] The database URL (jdbc\:h2\:...)\n[-user <user>] The user name\n[-password <pwd>] The password\n[-driver <class>] The JDBC driver class to use (not required in most cases)\nIf special characters don't work as expected, you may need to use\n -Dfile.encoding\=UTF-8 (Mac OS X) or CP850 (Windows). org.h2.tools.Shell.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-url "<url>"] The database URL (jdbc\:h2\:...)\n[-user <user>] The user name\n[-password <pwd>] The password\n[-driver <class>] The JDBC driver class to use (not required in most cases)\nIf special characters don't work as expected, you may need to use\n -Dfile.encoding\=UTF-8 (Mac OS X) or CP850 (Windows).
...@@ -83,4 +83,11 @@ public interface Service { ...@@ -83,4 +83,11 @@ public interface Service {
*/ */
int getPort(); int getPort();
/**
* Check if a daemon thread should be used.
*
* @return true if a daemon thread should be used
*/
boolean isDaemon();
} }
...@@ -59,6 +59,7 @@ public class TcpServer implements Service { ...@@ -59,6 +59,7 @@ public class TcpServer implements Service {
private Set<TcpServerThread> running = Collections.synchronizedSet(new HashSet<TcpServerThread>()); private Set<TcpServerThread> running = Collections.synchronizedSet(new HashSet<TcpServerThread>());
private String baseDir; private String baseDir;
private boolean allowOthers; private boolean allowOthers;
private boolean isDaemon;
private boolean ifExists; private boolean ifExists;
private Connection managementDb; private Connection managementDb;
private PreparedStatement managementDbAdd; private PreparedStatement managementDbAdd;
...@@ -161,6 +162,8 @@ public class TcpServer implements Service { ...@@ -161,6 +162,8 @@ public class TcpServer implements Service {
keyDatabase = args[++i]; keyDatabase = args[++i];
} else if ("-tcpAllowOthers".equals(a)) { } else if ("-tcpAllowOthers".equals(a)) {
allowOthers = true; allowOthers = true;
} else if ("-tcpDaemon".equals(a)) {
isDaemon = true;
} else if ("-ifExists".equals(a)) { } else if ("-ifExists".equals(a)) {
ifExists = true; ifExists = true;
} }
...@@ -211,6 +214,7 @@ public class TcpServer implements Service { ...@@ -211,6 +214,7 @@ public class TcpServer implements Service {
TcpServerThread c = new TcpServerThread(s, this, nextThreadId++); TcpServerThread c = new TcpServerThread(s, this, nextThreadId++);
running.add(c); running.add(c);
Thread thread = new Thread(c); Thread thread = new Thread(c);
thread.setDaemon(isDaemon);
thread.setName(threadName + " thread"); thread.setName(threadName + " thread");
c.setThread(thread); c.setThread(thread);
thread.start(); thread.start();
...@@ -455,4 +459,8 @@ public class TcpServer implements Service { ...@@ -455,4 +459,8 @@ public class TcpServer implements Service {
throw DbException.get(ErrorCode.WRONG_USER_OR_PASSWORD); throw DbException.get(ErrorCode.WRONG_USER_OR_PASSWORD);
} }
public boolean isDaemon() {
return isDaemon;
}
} }
...@@ -72,6 +72,7 @@ public class PgServer implements Service { ...@@ -72,6 +72,7 @@ public class PgServer implements Service {
private Set<PgServerThread> running = Collections.synchronizedSet(new HashSet<PgServerThread>()); private Set<PgServerThread> running = Collections.synchronizedSet(new HashSet<PgServerThread>());
private String baseDir; private String baseDir;
private boolean allowOthers; private boolean allowOthers;
private boolean isDaemon;
private boolean ifExists; private boolean ifExists;
public void init(String... args) { public void init(String... args) {
...@@ -86,6 +87,8 @@ public class PgServer implements Service { ...@@ -86,6 +87,8 @@ public class PgServer implements Service {
baseDir = args[++i]; baseDir = args[++i];
} else if ("-pgAllowOthers".equals(a)) { } else if ("-pgAllowOthers".equals(a)) {
allowOthers = true; allowOthers = true;
} else if ("-pgDaemon".equals(a)) {
isDaemon = true;
} else if ("-ifExists".equals(a)) { } else if ("-ifExists".equals(a)) {
ifExists = true; ifExists = true;
} }
...@@ -167,6 +170,7 @@ public class PgServer implements Service { ...@@ -167,6 +170,7 @@ public class PgServer implements Service {
running.add(c); running.add(c);
c.setProcessId(running.size()); c.setProcessId(running.size());
Thread thread = new Thread(c); Thread thread = new Thread(c);
thread.setDaemon(isDaemon);
thread.setName(threadName+" thread"); thread.setName(threadName+" thread");
c.setThread(thread); c.setThread(thread);
thread.start(); thread.start();
...@@ -450,4 +454,8 @@ public class PgServer implements Service { ...@@ -450,4 +454,8 @@ public class PgServer implements Service {
} }
} }
public boolean isDaemon() {
return isDaemon;
}
} }
...@@ -109,6 +109,7 @@ public class WebServer implements Service { ...@@ -109,6 +109,7 @@ public class WebServer implements Service {
// private URLClassLoader urlClassLoader; // private URLClassLoader urlClassLoader;
private int port; private int port;
private boolean allowOthers; private boolean allowOthers;
private boolean isDaemon;
private Set<WebThread> running = Collections.synchronizedSet(new HashSet<WebThread>()); private Set<WebThread> running = Collections.synchronizedSet(new HashSet<WebThread>());
private boolean ssl; private boolean ssl;
private HashMap<String, ConnectionInfo> connInfoMap = New.hashMap(); private HashMap<String, ConnectionInfo> connInfoMap = New.hashMap();
...@@ -227,6 +228,8 @@ public class WebServer implements Service { ...@@ -227,6 +228,8 @@ public class WebServer implements Service {
ssl = true; ssl = true;
} else if ("-webAllowOthers".equals(a)) { } else if ("-webAllowOthers".equals(a)) {
allowOthers = true; allowOthers = true;
} else if ("-webDaemon".equals(a)) {
isDaemon = true;
} else if ("-baseDir".equals(a)) { } else if ("-baseDir".equals(a)) {
String baseDir = args[++i]; String baseDir = args[++i];
SysProperties.setBaseDir(baseDir); SysProperties.setBaseDir(baseDir);
...@@ -691,4 +694,8 @@ public class WebServer implements Service { ...@@ -691,4 +694,8 @@ public class WebServer implements Service {
return translateThread.getFileName(); return translateThread.getFileName();
} }
public boolean isDaemon() {
return isDaemon;
}
} }
...@@ -69,7 +69,7 @@ ShutdownHandler { ...@@ -69,7 +69,7 @@ ShutdownHandler {
* <tr><td>[-tool]</td> * <tr><td>[-tool]</td>
* <td>Start the icon or window that allows to start a browser</td></tr> * <td>Start the icon or window that allows to start a browser</td></tr>
* <tr><td>[-browser]</td> * <tr><td>[-browser]</td>
* <td>Start a browser and open a page to connect to the web server</td></tr> * <td>Start a browser connecting to the web server</td></tr>
* <tr><td>[-tcp]</td> * <tr><td>[-tcp]</td>
* <td>Start the TCP server</td></tr> * <td>Start the TCP server</td></tr>
* <tr><td>[-pg]</td> * <tr><td>[-pg]</td>
......
...@@ -62,16 +62,20 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -62,16 +62,20 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
* <td>Start the web server with the H2 Console</td></tr> * <td>Start the web server with the H2 Console</td></tr>
* <tr><td>[-webAllowOthers]</td> * <tr><td>[-webAllowOthers]</td>
* <td>Allow other computers to connect - see below</td></tr> * <td>Allow other computers to connect - see below</td></tr>
* <tr><td>[-webDaemon]</td>
* <td>Use a daemon thread</td></tr>
* <tr><td>[-webPort &lt;port&gt;]</td> * <tr><td>[-webPort &lt;port&gt;]</td>
* <td>The port (default: 8082)</td></tr> * <td>The port (default: 8082)</td></tr>
* <tr><td>[-webSSL]</td> * <tr><td>[-webSSL]</td>
* <td>Use encrypted (HTTPS) connections</td></tr> * <td>Use encrypted (HTTPS) connections</td></tr>
* <tr><td>[-browser]</td> * <tr><td>[-browser]</td>
* <td>Start a browser and open a page to connect to the web server</td></tr> * <td>Start a browser connecting to the web server</td></tr>
* <tr><td>[-tcp]</td> * <tr><td>[-tcp]</td>
* <td>Start the TCP server</td></tr> * <td>Start the TCP server</td></tr>
* <tr><td>[-tcpAllowOthers]</td> * <tr><td>[-tcpAllowOthers]</td>
* <td>Allow other computers to connect - see below</td></tr> * <td>Allow other computers to connect - see below</td></tr>
* <tr><td>[-tcpDaemon]</td>
* <td>Use a daemon thread</td></tr>
* <tr><td>[-tcpPort &lt;port&gt;]</td> * <tr><td>[-tcpPort &lt;port&gt;]</td>
* <td>The port (default: 9092)</td></tr> * <td>The port (default: 9092)</td></tr>
* <tr><td>[-tcpSSL]</td> * <tr><td>[-tcpSSL]</td>
...@@ -79,21 +83,23 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -79,21 +83,23 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
* <tr><td>[-tcpPassword &lt;pwd&gt;]</td> * <tr><td>[-tcpPassword &lt;pwd&gt;]</td>
* <td>The password for shutting down a TCP server</td></tr> * <td>The password for shutting down a TCP server</td></tr>
* <tr><td>[-tcpShutdown "&lt;url&gt;"]</td> * <tr><td>[-tcpShutdown "&lt;url&gt;"]</td>
* <td>Stop the TCP server; example: tcp://localhost:9094</td></tr> * <td>Stop the TCP server; example: tcp://localhost</td></tr>
* <tr><td>[-tcpShutdownForce]</td> * <tr><td>[-tcpShutdownForce]</td>
* <td>Do not wait until all connections are closed</td></tr> * <td>Do not wait until all connections are closed</td></tr>
* <tr><td>[-pg]</td> * <tr><td>[-pg]</td>
* <td>Start the PG server</td></tr> * <td>Start the PG server</td></tr>
* <tr><td>[-pgAllowOthers]</td> * <tr><td>[-pgAllowOthers]</td>
* <td>Allow other computers to connect - see below</td></tr> * <td>Allow other computers to connect - see below</td></tr>
* <tr><td>[-pgDaemon]</td>
* <td>Use a daemon thread</td></tr>
* <tr><td>[-pgPort &lt;port&gt;]</td> * <tr><td>[-pgPort &lt;port&gt;]</td>
* <td>The port (default: 5435)</td></tr> * <td>The port (default: 5435)</td></tr>
* <tr><td>[-baseDir &lt;dir&gt;]</td> * <tr><td>[-baseDir &lt;dir&gt;]</td>
* <td>The base directory for H2 databases; for all servers</td></tr> * <td>The base directory for H2 databases (all servers)</td></tr>
* <tr><td>[-ifExists]</td> * <tr><td>[-ifExists]</td>
* <td>Only existing databases may be opened; for all servers</td></tr> * <td>Only existing databases may be opened (all servers)</td></tr>
* <tr><td>[-trace]</td> * <tr><td>[-trace]</td>
* <td>Print additional trace information; for all servers</td></tr> * <td>Print additional trace information (all servers)</td></tr>
* </table> * </table>
* The options -xAllowOthers are potentially risky. * The options -xAllowOthers are potentially risky.
* <br /> * <br />
...@@ -126,6 +132,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -126,6 +132,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
webStart = true; webStart = true;
} else if ("-webAllowOthers".equals(arg)) { } else if ("-webAllowOthers".equals(arg)) {
// no parameters // no parameters
} else if ("-webDaemon".equals(arg)) {
// no parameters
} else if ("-webSSL".equals(arg)) { } else if ("-webSSL".equals(arg)) {
// no parameters // no parameters
} else if ("-webPort".equals(arg)) { } else if ("-webPort".equals(arg)) {
...@@ -144,6 +152,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -144,6 +152,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
tcpStart = true; tcpStart = true;
} else if ("-tcpAllowOthers".equals(arg)) { } else if ("-tcpAllowOthers".equals(arg)) {
// no parameters // no parameters
} else if ("-tcpDaemon".equals(arg)) {
// no parameters
} else if ("-tcpSSL".equals(arg)) { } else if ("-tcpSSL".equals(arg)) {
// no parameters // no parameters
} else if ("-tcpPort".equals(arg)) { } else if ("-tcpPort".equals(arg)) {
...@@ -165,6 +175,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -165,6 +175,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
pgStart = true; pgStart = true;
} else if ("-pgAllowOthers".equals(arg)) { } else if ("-pgAllowOthers".equals(arg)) {
// no parameters // no parameters
} else if ("-pgDaemon".equals(arg)) {
// no parameters
} else if ("-pgPort".equals(arg)) { } else if ("-pgPort".equals(arg)) {
i++; i++;
} else { } else {
...@@ -329,6 +341,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -329,6 +341,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
try { try {
service.start(); service.start();
Thread t = new Thread(this); Thread t = new Thread(this);
t.setDaemon(service.isDaemon());
String name = service.getName() + " (" + service.getURL() + ")"; String name = service.getName() + " (" + service.getURL() + ")";
t.setName(name); t.setName(name);
t.start(); t.start();
......
...@@ -552,4 +552,8 @@ public class FtpServer extends Tool implements Service { ...@@ -552,4 +552,8 @@ public class FtpServer extends Tool implements Service {
return new Server(new FtpServer(), args); return new Server(new FtpServer(), args);
} }
public boolean isDaemon() {
return false;
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论