ginkgoctl stop can't cleanly stop daemonized service wrapped with ServerWrapper

65 views
Skip to first unread message

hw1979

unread,
May 9, 2012, 3:18:41 AM5/9/12
to ginkg...@googlegroups.com
hello,I've tried ginkgo today and found ginkgoctl stop can't cleanly stop daemonized service wrapped with ServerWrapper,here's the test code:

hello.py
import gevent
from ginkgo import Service, Setting
from ginkgo.async.gevent import ServerWrapper
from gevent.server import StreamServer
from gevent.socket import create_connection

class HelloWorld(Service):
    message = Setting("message", default="Hello World",
                      help="Message to print out while running")

    def do_start(self):
        self.spawn(self.message_forever)

    def message_forever(self):
        while True:
            print self.message
            self.async.sleep(1)
def handle_tcp(socket,address):
    print 'new tcp connection!'
    while True:
        socket.send('hello\n')
        gevent.sleep(1)

class HelloApplication(Service):
    def __init__(self):
        self.add_service(HelloWorld())
        self.add_service(
            ServerWrapper(
       StreamServer(
                    ('127.0.0.1',1234),
                    handle_tcp)
                )
            )


import os
import sys

daemon = bool(os.environ.get("DAEMONIZE", True))
message = "Services all the way down."
service = "hello.HelloApplication"
logfile = 'hello.log'
pidfile = 'hello.pid'

and the exception:

2012-05-09 14:33:07,853    INFO runner: Stopping.
Traceback (most recent call last):
  File "/home/hw1979/test/local/lib/python2.7/site-packages/gevent/greenlet.py", line 390, in run
    result = self._run(*self.args, **self.kwargs)
  File "/home/hw1979/test/local/lib/python2.7/site-packages/gevent/baseserver.py", line 146, in start
    self.pre_start()
  File "/home/hw1979/test/local/lib/python2.7/site-packages/gevent/server.py", line 95, in pre_start
    self._handle = self.handle
AttributeError: 'StreamServer' object has no attribute 'handle'
<Greenlet at 0xdc6f50: <bound method StreamServer.start of <StreamServer at 0xf2c390 fileno=3 address=127.0.0.1:1234>>> failed with AttributeError

Jeff Lindsay

unread,
May 10, 2012, 12:02:40 PM5/10/12
to ginkg...@googlegroups.com
Just to be clear, what version of gevent are you running? I'll see if I can reproduce and then investigate. 

-jeff
--
Jeff Lindsay
http://progrium.com

hw1979

unread,
May 14, 2012, 12:23:49 AM5/14/12
to ginkg...@googlegroups.com
I am using 0.13.7 installed by pip
also tried 1.0b2,seems the whole ginkgo service can't run anymore

在 2012年5月11日星期五UTC+8上午12时02分40秒,Jeff Lindsay写道:

Jeff Lindsay

unread,
May 17, 2012, 9:25:03 PM5/17/12
to ginkg...@googlegroups.com
So the latest master branch has a different API for working with gevent servers. You would use ginkgo.async.gevent.StreamServer instead of wrapping the gevent.servers.StreamServer in our ServerWrapper. So that's immediately actionable for you to stay up to date with our current sprint.

However, this probably won't fix the problem because it more or less does the same thing. So I would recommend filing this as a issue with all the information you provided here. 


-jeff
Reply all
Reply to author
Forward
0 new messages