File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# simple-python-webserver-blueprint
22
3- This is the blueprint example used for Cloudify's Intro section in our [ Docs] ( http://docs.get-cloudify .org ) .
3+ This is the blueprint example used for Cloudify's Intro section in our [ Docs] ( http://docs.getcloudify .org ) .
44
55The blueprint runs a local Python SimpleHTTPServer and allows to tear it down as well and supports Linux,
66
Original file line number Diff line number Diff line change 1111
1212
1313IS_WIN = os .name == 'nt'
14- IS_DARWIN = (sys .platform == 'darwin' )
1514
16- # Get the port from the blueprint. We're running in the context of the
17- # `http_web_server` node so we can read its `port` property.
15+ # Get the port from the blueprint. We're running this script in the context of
16+ # the `http_web_server` node so we can read its `port` property.
1817PORT = ctx .node .properties ['port' ]
1918
2019
@@ -26,18 +25,9 @@ def run_server():
2625 # The ctx object provides a built in logger.
2726 ctx .logger .info ('Running WebServer locally on port: {0}' .format (PORT ))
2827 # emulating /dev/null
29- dn = open (os .devnull , 'wb' )
30- process = subprocess .Popen (webserver_cmd , stdout = dn , stderr = dn )
31-
32- # we need this for linux because on linux process.pid is not accurate.
33- # it provides somewhat arbitrary values.
34- if not IS_WIN and not IS_DARWIN :
35- del webserver_cmd [0 ]
36- get_pid = ['pidof' , '-s' ]
37- get_pid .extend (webserver_cmd )
38- return int (subprocess .check_output (get_pid ))
39- else :
40- return process .pid
28+ with open (os .devnull , 'wb' ) as dn :
29+ process = subprocess .Popen (webserver_cmd , stdout = dn , stderr = dn )
30+ return process .pid
4131
4232
4333def set_pid (pid ):
You can’t perform that action at this time.
0 commit comments