Convert sky_server over to a go-based http server.
We keep seeing timeouts on the bots that seem to be due to cherrypy dropping requests on the floor, which in turn causes imports to stall, which causes the test to time out. In local testing, I was able to reproduce the timeouts and wasn't able to do so with the go-based server. R=abarth@chromium.org, eseidel@chromium.org Review URL: https://codereview.chromium.org/746373002
This commit is contained in:
20
engine/src/flutter/tools/download_sky_server
Executable file
20
engine/src/flutter/tools/download_sky_server
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright (c) 2014 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import subprocess
|
||||
|
||||
from webkitpy.common.system import filesystem
|
||||
from webkitpy.common.webkit_finder import WebKitFinder
|
||||
|
||||
finder = WebKitFinder(filesystem.FileSystem())
|
||||
|
||||
subprocess.call([
|
||||
'download_from_google_storage',
|
||||
'--no_resume',
|
||||
'--no_auth',
|
||||
'--bucket', 'mojo',
|
||||
'--sha1_file', finder.path_from_chromium_base('sky', 'tools', 'skygo', 'sky_server.sha1'),
|
||||
'--output', finder.path_from_chromium_base('out', 'downloads', 'sky_server')
|
||||
])
|
||||
@@ -1,81 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import argparse
|
||||
import cherrypy
|
||||
import json
|
||||
import os
|
||||
import staticdirindex
|
||||
from skypy.paths import Paths
|
||||
import skypy.configuration as configuration
|
||||
|
||||
def skydir(section="", dir="", path="", **kwargs):
|
||||
if cherrypy.request.params.get('format') is None:
|
||||
return '<sky><import src="/sky/examples/file-browser.sky"/><file-browser/></sky>'
|
||||
result = dict()
|
||||
result['directories'] = []
|
||||
result['files'] = []
|
||||
for _, dir_names, file_names in os.walk(path.rstrip(r"\/")):
|
||||
for dir_name in sorted(dir_names):
|
||||
result["directories"].append(dir_name)
|
||||
|
||||
del dir_names[:] # limit to one level
|
||||
|
||||
for file_name in sorted(file_names):
|
||||
result["files"].append(file_name)
|
||||
return json.dumps(result)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Sky development server')
|
||||
parser.add_argument('-v', '--verbose', action='store_true',
|
||||
help='Enable logging to the console.')
|
||||
parser.add_argument('app_path', type=str)
|
||||
parser.add_argument('port', type=int)
|
||||
configuration.add_arguments(parser)
|
||||
args = parser.parse_args()
|
||||
|
||||
log_dir = os.path.abspath(os.getcwd())
|
||||
|
||||
paths = Paths(os.path.join('out', args.configuration))
|
||||
|
||||
config = {
|
||||
'global': {
|
||||
# Cherrypy appears to just drop requests if it doesn't have
|
||||
# a thread to service them, so set our thread_pool high enough
|
||||
# so that a z620 can run all the tests w/o timeouts.
|
||||
'server.thread_pool': 30,
|
||||
'server.socket_port': args.port,
|
||||
'tools.staticdir.content_types' : {
|
||||
'sky': 'text/sky',
|
||||
},
|
||||
'log.screen': args.verbose,
|
||||
'log.access_log': os.path.join(log_dir, 'access_log.txt'),
|
||||
# This causes some strange python exception??
|
||||
# 'log.error_log': os.path.join(log_dir, 'error_log.txt'),
|
||||
},
|
||||
'/': {
|
||||
'tools.staticdir.on': True,
|
||||
'tools.staticdir.dir': os.path.abspath(args.app_path),
|
||||
'tools.staticdir.indexlister': skydir,
|
||||
},
|
||||
'/mojo/public': {
|
||||
'tools.staticdir.on': True,
|
||||
'tools.staticdir.dir': os.path.join(paths.gen_root, 'mojo', 'public'),
|
||||
},
|
||||
'/mojo/services': {
|
||||
'tools.staticdir.on': True,
|
||||
'tools.staticdir.dir': os.path.join(paths.gen_root, 'mojo', 'services'),
|
||||
},
|
||||
'/sky/services': {
|
||||
'tools.staticdir.on': True,
|
||||
'tools.staticdir.dir': os.path.join(paths.gen_root, 'sky', 'services'),
|
||||
},
|
||||
}
|
||||
cherrypy.quickstart(config=config)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -50,8 +50,10 @@ class SkyDebugger(object):
|
||||
'Port %s already in use, assuming custom sky_server started.' %
|
||||
HTTP_PORT)
|
||||
else:
|
||||
subprocess.call(os.path.join(self.paths.sky_tools_directory,
|
||||
'download_sky_server'))
|
||||
server_command = [
|
||||
os.path.join(self.paths.sky_tools_directory, 'sky_server'),
|
||||
os.path.join(self.paths.src_root, 'out', 'downloads', 'sky_server'),
|
||||
'-t', configuration,
|
||||
server_root,
|
||||
str(HTTP_PORT),
|
||||
|
||||
19
engine/src/flutter/tools/skygo/README
Normal file
19
engine/src/flutter/tools/skygo/README
Normal file
@@ -0,0 +1,19 @@
|
||||
sky_server instructions
|
||||
#######################
|
||||
|
||||
Building locally:
|
||||
1. cd sky/tools/skygo
|
||||
2. go build sky_server.go
|
||||
|
||||
Testing locally:
|
||||
1. Build as per the above steps
|
||||
2. Run test_sky --path-to-server /absolute/path/to/sky/tools/skygo/sky_server
|
||||
|
||||
Uploading the locally built server
|
||||
1. cd sky/tools/skygo
|
||||
2. upload_to_google_storage.py --bucket mojo sky_server
|
||||
|
||||
upload_to_google_storage.py is in depot_tools. It will overwrite
|
||||
sky_server.sha1. Include that change in your code review.
|
||||
|
||||
sky_server was last built using go version go1.3 linux/amd64.
|
||||
46
engine/src/flutter/tools/skygo/sky_server.go
Normal file
46
engine/src/flutter/tools/skygo/sky_server.go
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright (c) 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type skyHandlerRoot struct {
|
||||
root string
|
||||
}
|
||||
|
||||
func skyHandler(root string) http.Handler {
|
||||
return &skyHandlerRoot{root}
|
||||
}
|
||||
|
||||
func (handler *skyHandlerRoot) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
path := path.Join(handler.root, r.URL.Path)
|
||||
if strings.HasSuffix(path, ".sky") {
|
||||
w.Header().Set("Content-Type", "text/sky")
|
||||
}
|
||||
http.ServeFile(w, r, path)
|
||||
}
|
||||
|
||||
func main() {
|
||||
var configuration = flag.String("t", "Release", "The target configuration (i.e. Release or Debug)")
|
||||
flag.Parse()
|
||||
|
||||
args := flag.Args()
|
||||
root := args[0]
|
||||
port := args[1]
|
||||
|
||||
genRoot := path.Join(root, "out", *configuration, "gen")
|
||||
|
||||
http.Handle("/", skyHandler(root))
|
||||
http.Handle("/mojo/public/", http.StripPrefix("/mojo/public/", skyHandler(path.Join(genRoot, "mojo", "public"))))
|
||||
http.Handle("/mojo/services/", http.StripPrefix("/mojo/services/", skyHandler(path.Join(genRoot, "mojo", "services"))))
|
||||
http.Handle("/sky/services/", http.StripPrefix("/sky/services/", skyHandler(path.Join(genRoot, "sky", "services"))))
|
||||
|
||||
http.ListenAndServe(":" + port, nil)
|
||||
}
|
||||
1
engine/src/flutter/tools/skygo/sky_server.sha1
Normal file
1
engine/src/flutter/tools/skygo/sky_server.sha1
Normal file
@@ -0,0 +1 @@
|
||||
7b6d0d60949ad71a35a88430b2eb7d70fe7334b6
|
||||
@@ -69,8 +69,10 @@ class PerfHarness(object):
|
||||
self.args = args
|
||||
|
||||
def _start_server(self):
|
||||
subprocess.call(os.path.join(self.paths.sky_tools_directory,
|
||||
'download_sky_server'))
|
||||
return subprocess.Popen([
|
||||
os.path.join(self.paths.sky_tools_directory, 'sky_server'),
|
||||
os.path.join(self.paths.src_root, 'out', 'downloads', 'sky_server'),
|
||||
self.paths.src_root,
|
||||
str(HTTP_PORT),
|
||||
'-t', self.args.configuration
|
||||
|
||||
Reference in New Issue
Block a user