Skip to content
Snippets Groups Projects
Commit ee2c699a authored by Chris Hines's avatar Chris Hines
Browse files

refactor for easy install of a local backend

parent 7c4206aa
No related branches found
No related tags found
4 merge requests!77Revert "disable agressive kill and restart",!35Dev,!30Test,!29Dev
Pipeline #10689 passed
0OFH6H3L5EHLX1V3:
last: 2018-05-31 16:16:11.815938
pids: [27653, 27654]
port: 1028
11UMLN50KEVM5ZII:
last: 2018-06-01 13:31:17.946453
pids: [10304]
port: 1030
25XP439TQFMYLM72:
last: 2018-05-18 16:28:24.735311
pids: [6465, 6466]
port: 1042
3LKUEY1OGKA6CINK:
last: 2018-05-18 14:53:22.713145
pids: [2794, 2795]
port: 1040
3ON0HGFE8EQDXES4:
last: 2018-06-01 13:24:00.184654
pids: [10026]
port: 1027
3VH4SSCNMXFDX0D0:
last: 2018-06-12 10:03:15.228129
pids: [22046, 22047]
port: 1026
44PUTVFZUCLFI9YL:
last: 2018-05-31 17:38:30.910803
pids: [31346, 31347]
port: 1038
50SDE3TPU5HGQ7P9:
last: 2018-06-12 11:59:06.360102
pids: [28240]
port: 1025
57QI18XHLG7K7ZMT:
last: 2018-05-31 16:41:58.442540
pids: [29083]
port: 1029
5CZSBZDQLL9PBO7Q:
last: 2018-06-12 09:46:49.797598
pids: [21211]
port: 1025
6877U2A1MXV16FHU:
last: 2018-06-12 09:56:40.503855
pids: [21697]
port: 1025
6WLJ6NG7J013FCE7:
last: 2018-06-12 11:59:56.253466
pids: [28266, 28267]
port: 1027
7NLXEZOJNA868RTD:
last: 2018-05-31 17:44:19.397577
pids: [31639, 31640]
port: 1026
9EU7M2ARUA2A8X4V:
last: 2018-05-18 14:46:09.481491
pids: [2372, 2373]
port: 1038
DDDOC408J9BAE0EE:
last: 2018-06-01 13:19:07.421463
pids: [9882]
port: 1026
EECM84RR90VZ4SY1:
last: 2018-05-18 16:29:07.324242
pids: [6525, 6526]
port: 1044
EKH9V7L84DZTL8CQ:
last: 2018-06-01 13:25:08.069383
pids: [10061]
port: 1028
EM4NR1MSIFTWCKAF:
last: 2018-06-01 13:14:02.468644
pids: [9664]
port: 1025
FEACFO2DQAQO1FRI:
last: 2018-05-18 14:43:39.968655
pids: [2245, 2246]
port: 1036
FM3Q62U76NFLRDM5:
last: 2018-05-18 14:40:34.011913
pids: [2117, 2118]
port: 1034
GFA9CRNDVUB2FC3S:
last: 2018-06-12 09:51:06.105147
pids: [21396]
port: 1027
GFDC47CES60NQK2S:
last: 2018-06-12 10:00:56.808640
pids: [21922]
port: 1025
GY14BY2HFKAKLXNW:
last: 2018-05-31 17:10:06.575603
pids: [30151, 30166]
port: 1036
HDBXJAM60NN8UYKN:
last: 2018-06-12 09:48:47.349297
pids: [21299]
port: 1026
IWTYOSC9P3C88L66:
last: 2018-05-18 14:28:59.928858
pids: [1538, 1539]
port: 1030
J2GTTU1LTTQAIB9G:
last: 2018-06-01 13:33:52.002715
pids: [10406]
port: 1032
J5RQC3W794W6NBOG:
last: 2018-06-01 13:32:36.903635
pids: [10349]
port: 1031
KH33DBI27EA7QZZ8:
last: 2018-05-31 16:43:19.556851
pids: [29136]
port: 1030
N4R4ETVNLP02EGKJ:
last: 2018-05-31 16:14:38.321058
pids: [27576, 27577]
port: 1026
O117RCJ5PR3IEXAI:
last: 2018-05-31 17:05:08.724101
pids: [29958, 29959]
port: 1034
POLM8ID6CWERZFP8:
last: 2018-05-31 16:15:28.824716
pids: [27616, 27617]
port: 1026
QWR64SMKWKI6VJ5P:
last: 2018-05-18 14:34:44.989185
pids: [1749, 1750]
port: 1032
S63OZK674UCHMBS5:
last: 2018-06-01 15:19:04.935998
pids: [15193]
port: 1033
SY70T5TS9SXXS0M3:
last: 2018-05-31 17:42:10.481577
pids: [31560, 31561]
port: 1027
UJW04R6V7WNNNN1Y:
last: 2018-06-12 12:00:29.055837
pids: [28310, 28311]
port: 1029
YA80F1WKXVTRT6H5:
last: 2018-05-31 17:03:20.825036
pids: [29908, 29909]
port: 1032
Z4O4VMOK00LVKDPK:
last: 2018-06-01 13:29:40.028528
pids: [10225]
port: 1029
def main():
def tesserver():
from tes import app
import logging
logging.basicConfig(filename="tes.log",format="%(asctime)s %(levelname)s:%(process)s: %(message)s")
logger=logging.getLogger()
logger.setLevel(logging.DEBUG)
app.config['ENABLELAUNCH'] = True
from flask_cors import CORS, cross_origin
CORS(app, supports_credentials=True, origin="*")
print("try to run tesserver")
app.run(host='localhost',debug=False,port=8080)
print('app is running')
def tws():
from twsproxy import server
import sys
import os
import logging
port = 8090
logger=logging.getLogger()
if port is None:
try:
port = int(sys.argv[1])
except:
port = 8090
server = server.TWSServer(port,5)
logger.debug("initialised server object")
server.run()
CORS(app, supports_credentials=True, origin="*")
app.run(host='localhost',debug=True,port=8080)
def main():
import logging
logging.basicConfig(filename="tes.log",format="%(asctime)s %(levelname)s:%(process)s: %(message)s")
logger=logging.getLogger()
logger.setLevel(logging.DEBUG)
import threading
print("create thread")
twsthread = threading.Thread(target=tws)
twsthread.start()
print("thread started")
tesserver()
twsthread.join()
if __name__ == "__main__":
main()
......@@ -473,7 +473,7 @@ class AppLaunch(Resource):
#flask_restful.abort(500,message="AppUrl failed in some unexpected way")
return apiabort(500,message="AppUrl failed in some unexpected way")
logger.debug('application launched, returning')
return {'msg':'launch success'}, 200
return None, 200
class AppInstance(Resource):
def get(self, username, loginhost, batchhost, jobid):
......
......@@ -211,15 +211,23 @@ class TWSProxy(threading.Thread):
dest.shutdown(shuttype)
initshutdown.set()
def main():
def mainserver(port=None):
from . import server
import logging
import sys
logging.basicConfig(filename="/var/log/tws.log",format="%(asctime)s %(levelname)s:%(process)s: %(message)s")
import os
try:
logging.basicConfig(filename="/var/log/tws.log",format="%(asctime)s %(levelname)s:%(process)s: %(message)s")
except:
logging.basicConfig(filename=os.path.expanduser("~/.tws.log"),format="%(asctime)s %(levelname)s:%(process)s: %(message)s")
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
logger.debug("starting TWS proxy")
port = int(sys.argv[1])
if port is None:
try:
port = int(sys.argv[1])
except:
port = 8090
server = server.TWSServer(port,5)
logger.debug("initialised server object")
server.run()
......@@ -6,21 +6,27 @@ class TWSServer:
def __init__(self,port,maxconn):
self.port = port
print('init tws proxy')
print(port)
self.maxconn = maxconn
def run(self):
logger = logging.getLogger()
serversocket = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
print(serversocket)
#bind the socket to a public host,
# and a well-known port
for port in range(self.port,self.port+1):
try:
print('try bind to {}'.format(port))
serversocket.bind(('0.0.0.0', port))
print("bind success")
#become a server socket
serversocket.listen(self.maxconn)
break
except Exception as e:
print("bind fail")
print(e)
pass
openconnections = []
......
......@@ -4,15 +4,10 @@ def main():
passwd = sys.argv[2]
import subprocess
passwd = passwd + '\n'
p = subprocess.Popen(['vncviewer','-autopass','localhost::{}'.format(port)],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
p = subprocess.Popen(['vncviewer','-autopass','localhost::{}'.format(port)],stdin=subprocess.PIPE,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
p.stdin.write(passwd.encode())
p.stdin.close()
if p.poll() == None:
sys.exit(0)
else:
sys.stderr.write(p.stderr.read())
sys.exit(1)
if __name__ == "__main__":
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment