Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 瓶当量的发动机。重新启动()_Python_Cherrypy_Gevent_Bottle - Fatal编程技术网

Python 瓶当量的发动机。重新启动()

Python 瓶当量的发动机。重新启动(),python,cherrypy,gevent,bottle,Python,Cherrypy,Gevent,Bottle,我正在尝试从Cherrypy转移到Bottle&Gevent(服务器)。 在我跑步之后: application=bottle.default_app() #bottle WSGIServer(('', port), application, spawn=None).serve_forever() #gevent 我希望重新启动服务器,就像重新加载程序重新加载服务器一样(但仅当我告诉服务器重新加载时)。 所以我想访问一个带有凭证请求的页面,只有在正确的身份验证之后,它才会重新启动 下面是我在C

我正在尝试从Cherrypy转移到Bottle&Gevent(服务器)。
在我跑步之后:

application=bottle.default_app() #bottle
WSGIServer(('', port), application, spawn=None).serve_forever() #gevent
我希望重新启动服务器,就像重新加载程序重新加载服务器一样(但仅当我告诉服务器重新加载时)。
所以我想访问一个带有凭证请求的页面,只有在正确的身份验证之后,它才会重新启动

下面是我在Cherrypy中的函数示例:

@expose
def reloadMe(self, u=None, p=None):
    if u=="username" and p=="password":
        engine.restart()
    raise HTTPRedirect('/')
更简单地说,我是在问如何重新加载此脚本,以便实现对源文件的编辑,但只有在检索“重新启动”页面时才执行编辑。
我只需要一瓶相当于

engine.restart() #cherrypy

没有人知道怎么做吗?

您可以编写一个小的shell脚本来重新启动gevent wsgi服务器

然后使用此代码,您可以调用脚本

@get('/restartmyserver')
def handler():
    http_auth_data = bottle.request.auth() # returns a tuple (username,password) only basic auth.
    if http_auth_data[0] == user and http_auth_data[1] == password:
        os.system("your_shell_script_to_restart_gevent_wsgi")
    bottle.redirect('/')

如果您需要更多信息,请告诉我。

看看这对我没有帮助。我只希望在告诉服务器重新加载时重新加载服务器,而不是在服务器文件更新时重新加载。我有一个我想要的例子,除了它是为Cherrypy编写的。哦,天哪,我完全没有考虑重新运行脚本-。-但是:
os.system()
os.exec()
os.popen()
os.spawn()中的哪一个
最好,因为我不希望它保持当前进程运行,但我不介意它保持相同的标识符?在shell脚本中,您可以首先“killall”gevent进程。然后创建新的。此外,一旦shell脚本完成,它的进程将自动销毁。瓶子也会回来的。您可以使用os.system()进行此操作。