pgServer Shutdown?

57 views
Skip to first unread message

Chris Tusa

unread,
Dec 8, 2010, 12:17:25 AM12/8/10
to h2-da...@googlegroups.com
Hi Thomas,

I had posted a message a few weeks back about a *nix Bash init script, and I am continuing my improvements. In particular I am interested in this for a project where I am using PowerDNS-backend-postgresql to host a DNS server but using H2 with pgserver. I did have success in using H2 as the backend for PowerDNS in this way, but as part of my project, I need to be able to have an initscript start/stop the database instance, and in this case, the pgServer in particular.

I noticed when running H2 from the command line via JAR file, that the pgServer does not have a Shutdown option as does the tcpServer. I am running the SSL version of the tcpServer, and am able to stop it just fine using the following command:

java -cp $H2_HOME/h2.jar org.h2.tools.Server -tcpShutdown "ssl://localhost:9010"

If the pgServer was started at the same time as the tcpServer (Default or with '-pg' option), then the shutdown command halts the tcpServer, but the original java process is still running and there is no apparent way to stop the pgServer.
  
Is there anyway to shutdown the pgServer other than to issue a SIGTERM or SIGKILL to the java process?

Chris Tusa


Thomas Mueller

unread,
Dec 9, 2010, 2:17:46 PM12/9/10
to h2-da...@googlegroups.com
Hi,

Currently you need to kill the Java process, unless you use some
tricks (for example stop the process using JMX or so).

I guess it would make sense if -tcpShutdown would also stop the
pgServer (and webServer) listeners if those were started at the same
time, using

java ... -tcp -pg

I will implement this (not sure if for the next release already). What
do you think?

Regards,
Thomas

Chris Tusa

unread,
Dec 9, 2010, 11:46:05 PM12/9/10
to H2 Database
Thomas,

Thanks for the answer. It would be helpful to shutdown the entire
server (tcp & pg together) without using 'kill'. I think at minimum
providing a '-pgShutdown' to stop the pgServer would be immediately
helpful. On this same thought, I also don't know the side-effects of
starting them separate. Does running two separate servers (1 as tcp
and the other as pg in different Java processes) have any impact on
locking or lead to possible data corruption when accessing the same
database? I'm guessing it does.

Also, have you considered setting up a Wiki Doc so user's can
contribute how-to's ? I'd be happy to contribute. I think JamWiki
works with H2.

Cheers,
Chris




On Dec 9, 12:17 pm, Thomas Mueller <thomas.tom.muel...@gmail.com>
wrote:

Thomas Mueller

unread,
Jan 11, 2011, 12:46:06 AM1/11/11
to h2-da...@googlegroups.com
Hi,

In the newest version, the PG server is now stopped as well when using
tcpShutdown.

Regards,
Thomas

Chris Tusa

unread,
Jan 12, 2011, 12:25:41 AM1/12/11
to H2 Database
Thomas,

Saw it posted in the latest changelog, and already tested. Thanks!

Chris

On Jan 10, 10:46 pm, Thomas Mueller <thomas.tom.muel...@gmail.com>
wrote:

kensystem

unread,
Mar 31, 2011, 11:18:08 AM3/31/11
to h2-da...@googlegroups.com
I tried using -tcpShutdown, but I may be doing something wrong.. it says the server is trying to start up:

>java -jar /tomcat/h2db/h2-1.3.152.jar org.h2.tools.Server -tcpShutdown tcp://localhost
The Web Console server could not be started. Possible cause: another server is already running at http://localhost:8082
Root cause: Exception opening port "8082" (port may be in use), cause: "java.net.BindException: Address already in use" [90061-152]
The TCP server could not be started. Possible cause: another server is already running at tcp://localhost:9101
Root cause: Exception opening port "9101" (port may be in use), cause: "java.net.BindException: Address already in use" [90061-152]
PG server running at pg://localhost:37757 (only local connections)
Exception in thread "main" org.h2.jdbc.JdbcSQLException: Exception opening port "8082" (port may be in use), cause: "java.net.BindException: Address already in use" [90061-152]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
        at org.h2.message.DbException.get(DbException.java:156)
        at org.h2.util.NetUtils.createServerSocketTry(NetUtils.java:175)
        at org.h2.util.NetUtils.createServerSocket(NetUtils.java:141)
        at org.h2.server.web.WebServer.start(WebServer.java:329)
        at org.h2.tools.Server.start(Server.java:362)
        at org.h2.tools.Console.runTool(Console.java:173)
        at org.h2.tools.Console.main(Console.java:101)
Caused by: java.net.BindException: Address already in use
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)
        at java.net.ServerSocket.bind(ServerSocket.java:319)
        at java.net.ServerSocket.<init>(ServerSocket.java:185)
        at java.net.ServerSocket.<init>(ServerSocket.java:97)
        at org.h2.util.NetUtils.createServerSocketTry(NetUtils.java:171)
        ... 5 more

I tried several variations but same result:
>java -jar /tomcat/h2db/h2-1.3.152.jar org.h2.tools.Server -tcpPort 9101 -tcpShutdown tcp://localhost
>java -jar /tomcat/h2db/h2-1.3.152.jar org.h2.tools.Server -tcpShutdown tcp://localhost:9101

Am I doing something wrong?

Thomas Mueller

unread,
Mar 31, 2011, 4:16:19 PM3/31/11
to h2-da...@googlegroups.com
Hi,

Please use "java -cp ..." instead of "java -jar ...".

Regards,
Thomas

> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To post to this group, send email to h2-da...@googlegroups.com.
> To unsubscribe from this group, send email to
> h2-database...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/h2-database?hl=en.
>

kensystem

unread,
Mar 31, 2011, 11:59:24 PM3/31/11
to H2 Database
Yes sir, that worked! Thank you.

-ken

On Mar 31, 2:16 pm, Thomas Mueller <thomas.tom.muel...@gmail.com>
wrote:
> Hi,
>
> Please use "java -cp ..." instead of "java -jar ...".
>
> Regards,
> Thomas
>
>
>
>
>
>
>
> On Thu, Mar 31, 2011 at 5:18 PM, kensystem <kensys...@gmail.com> wrote:
> > I tried using -tcpShutdown, but I may be doing something wrong.. it says the
> > server is trying to start up:
>
> >>java -jar /tomcat/h2db/h2-1.3.152.jar org.h2.tools.Server -tcpShutdown
> >> tcp://localhost
> > The Web Console server could not be started. Possible cause: another server
> > is already running athttp://localhost:8082
Reply all
Reply to author
Forward
0 new messages