-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart_geoserver.py
44 lines (30 loc) · 1014 Bytes
/
start_geoserver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""Start Geoserver instance
"""
import sys, os, time, commands
import urllib
import platform
from install_geoserver import run_startup
# This is the local address for the server running on host
geoserver_url = 'http://localhost:8080/geoserver'
# Stop any geoserver process first
execfile('stop_geoserver.py')
# Install and start new geoserver
print 'Starting Geoserver (please wait 20-30 seconds or so)'
cmd = 'sudo python __geoserver_start__.py > geoserver.log 2> geoserver.err &'
os.system(cmd)
# Wait until ready
t0 = time.time()
time_out = 60 # Wait no more than these many seconds
running = False
while not running and time.time()-t0 < time_out:
time.sleep(1)
try:
fid = urllib.urlopen(geoserver_url)
except IOError, e:
running = False
else:
running = True
if not running:
raise Exception('Geoserver did not start.')
else:
print 'Geoserver ready at %s (installed in %i seconds).' % (geoserver_url, time.time()-t0)