File tree Expand file tree Collapse file tree 2 files changed +6
-16
lines changed Expand file tree Collapse file tree 2 files changed +6
-16
lines changed Original file line number Diff line number Diff line change 1
1
# simple-python-webserver-blueprint
2
2
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 ) .
4
4
5
5
The blueprint runs a local Python SimpleHTTPServer and allows to tear it down as well and supports Linux,
6
6
Original file line number Diff line number Diff line change 11
11
12
12
13
13
IS_WIN = os .name == 'nt'
14
- IS_DARWIN = (sys .platform == 'darwin' )
15
14
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.
18
17
PORT = ctx .node .properties ['port' ]
19
18
20
19
@@ -26,18 +25,9 @@ def run_server():
26
25
# The ctx object provides a built in logger.
27
26
ctx .logger .info ('Running WebServer locally on port: {0}' .format (PORT ))
28
27
# 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
41
31
42
32
43
33
def set_pid (pid ):
You can’t perform that action at this time.
0 commit comments