def execute(self): try: #Batch() #Command.execute_cmd(timed_trigger) Project.set_project(self.project_code) timed_triggers[self.index].execute() except Exception as e: raise finally: DbContainer.close_thread_sql() DbContainer.commit_thread_sql() DbContainer.close_all()
def execute(self): try: #Batch() #Command.execute_cmd(timed_trigger) Project.set_project(self.project_code) timed_triggers[self.index].execute() except Exception as e: raise finally: DbContainer.close_thread_sql() DbContainer.commit_thread_sql() DbContainer.close_all()
def execute(self): import atexit import time atexit.register(self.cleanup) while 1: self.check_existing_jobs() self.check_new_job() time.sleep(self.check_interval) DbContainer.close_thread_sql() if self.max_jobs_completed != -1 and self.jobs_completed > self.max_jobs_completed: Common.restart() while 1: print("Waiting to restart...") time.sleep(1)
def execute(my): import atexit import time atexit.register( my.cleanup ) while 1: my.check_existing_jobs() my.check_new_job() time.sleep(my.check_interval) DbContainer.close_thread_sql() if my.max_jobs_completed != -1 and my.jobs_completed > my.max_jobs_completed: Common.restart() while 1: print "Waiting to restart..." time.sleep(1)
def execute(my): import atexit import time atexit.register(my.cleanup) while 1: my.check_existing_jobs() my.check_new_job() time.sleep(my.check_interval) DbContainer.close_thread_sql() if my.max_jobs_completed != -1 and my.jobs_completed > my.max_jobs_completed: Common.restart() while 1: print "Waiting to restart..." time.sleep(1)
def execute(self): import atexit import time atexit.register( self.cleanup ) while 1: self.check_existing_jobs() self.check_new_job() time.sleep(self.check_interval) DbContainer.close_thread_sql() if self.max_jobs_completed != -1 and self.jobs_completed > self.max_jobs_completed: Common.restart() while 1: print("Waiting to restart...") time.sleep(1)
def execute(my): # check to see the status of this job """ job = my.kwargs.get('job') job_code = job.get_code() search = Search("sthpw/queue") search.add_filter("code", job_code) my.kwargs['job'] = search.get_sobject() if not job: print "Cancelling ..." return state = job.get_value("state") if state == "cancel": print "Cancelling 2 ...." return """ subprocess_kwargs = { 'login': login, 'project_code': project_code, 'command': command, 'kwargs': kwargs } subprocess_kwargs_str = jsondumps(subprocess_kwargs) install_dir = Environment.get_install_dir() python = Config.get_value("services", "python") if not python: python = 'python' args = [ '%s' % python, '%s/src/tactic/command/queue.py' % install_dir ] args.append(subprocess_kwargs_str) import subprocess p = subprocess.Popen(args) DbContainer.close_thread_sql() return
def execute(self): # check to see the status of this job """ job = self.kwargs.get('job') job_code = job.get_code() search = Search("sthpw/queue") search.add_filter("code", job_code) self.kwargs['job'] = search.get_sobject() if not job: print("Cancelling ...") return state = job.get_value("state") if state == "cancel": print("Cancelling 2 ....") return """ subprocess_kwargs = { 'login': login, 'project_code': project_code, 'command': command, 'kwargs': kwargs } subprocess_kwargs_str = jsondumps(subprocess_kwargs) install_dir = Environment.get_install_dir() python = Config.get_value("services", "python") if not python: python = 'python' args = ['%s' % python, '%s/src/tactic/command/queue.py' % install_dir] args.append(subprocess_kwargs_str) import subprocess p = subprocess.Popen(args) DbContainer.close_thread_sql() return
def run(my): try: Batch() timed_trigger._do_execute() finally: DbContainer.close_thread_sql()
def run(self): try: Batch() timed_trigger._do_execute() finally: DbContainer.close_thread_sql()
def run(self): import time time.sleep(6) #print("Starting Timed Trigger") # checks are done every 60 seconds chunk = 60 # FIXME: not sure why we have to do a batch here from pyasm.security import Batch Batch(login_code="admin") # get the all of the timed triggers #search = Search("sthpw/timed_trigger") #search.add_filter("type", "timed") search = Search("sthpw/trigger") search.add_filter("event", "timed") timed_trigger_sobjs = search.get_sobjects() timed_triggers = [] for trigger_sobj in timed_trigger_sobjs: trigger_class = trigger_sobj.get_value("class_name") try: timed_trigger = Common.create_from_class_path(trigger_class) except ImportError: raise Exception("WARNING: [%s] does not exist" % trigger_class) timed_triggers.append(timed_trigger) while 1: time.sleep(chunk) #print("Running timer") date = Date() #print("utc: ", date.get_display_time()) # go through each trigger for timed_trigger in timed_triggers: if not timed_trigger.is_ready(): continue if timed_trigger.is_in_separate_thread(): class xxx(threading.Thread): def run(self): try: Batch() timed_trigger._do_execute() finally: DbContainer.close_thread_sql() xxx().start() else: timed_trigger._do_execute() DbContainer.close_thread_sql() if self.end: #print("Stopping timed thread") break
def execute(my): from pyasm.security import Batch Batch(login_code="admin") os.environ["TACTIC_MONITOR"] = "true" if not my.num_processes: my.num_processes = Config.get_value("services", "process_count") if my.num_processes: my.num_processes = int(my.num_processes) else: my.num_processes = 3 start_port = Config.get_value("services", "start_port") ports_str = os.environ.get("TACTIC_PORTS") if not ports_str: ports_str = Config.get_value("services", "ports") if ports_str: ports = ports_str.split("|") ports = [int(x) for x in ports] else: if start_port: start_port = int(start_port) else: start_port = 8081 ports = [] for i in range(0, my.num_processes): ports.append( start_port + i ) tactic_threads = [] # create a number of processes use_tactic = Config.get_value("services", "tactic") if use_tactic != 'false': #for i in range(0, my.num_processes): for port in ports: # start cherrypy tactic_thread = TacticThread(port) tactic_thread.set_dev(my.dev_mode) tactic_thread.start() tactic_threads.append(tactic_thread) time.sleep(1) #port += 1 # Job Queue services use_job_queue = Config.get_value("services", "job_queue") if use_job_queue == 'true': num_processes = Config.get_value("services", "queue_process_count") if not num_processes: num_processes = 1 else: num_processes = int(num_processes) for i in range(0, num_processes): job_thread = JobQueueThread() job_thread.start() tactic_threads.append(job_thread) # create a separate thread for timed processes # DEPRECATED tactic_timed_thread = TacticTimedThread() tactic_timed_thread.start() tactic_threads.append(tactic_timed_thread) # create a separate thread for scheduler processes use_scheduler = Config.get_value("services", "scheduler") if use_scheduler == 'true': tactic_scheduler_thread = TacticSchedulerThread() tactic_scheduler_thread.start() tactic_threads.append(tactic_scheduler_thread) DbContainer.close_thread_sql() # check each thread every 20 seconds while 1: end = False try: if my.check_interval: time.sleep(my.check_interval) for tactic_thread in tactic_threads: tactic_thread._check() else: # FIXME: break for now (for windows service) break except KeyboardInterrupt, e: print "Keyboard interrupt ... exiting Tactic" for tactic_thread in tactic_threads: tactic_thread.end = True end = True if end: break
def _execute(self): '''if mode is normal, this runs both the main startup (init) logic plus monitor''' from pyasm.security import Batch Batch(login_code="admin") os.environ["TACTIC_MONITOR"] = "true" if not self.num_processes: self.num_processes = Config.get_value("services", "process_count") if self.num_processes: self.num_processes = int(self.num_processes) else: self.num_processes = 3 start_port = Config.get_value("services", "start_port") ports_str = os.environ.get("TACTIC_PORTS") if not ports_str: ports_str = Config.get_value("services", "ports") if ports_str: ports = ports_str.split("|") ports = [int(x) for x in ports] else: if start_port: start_port = int(start_port) else: start_port = 8081 ports = [] for i in range(0, self.num_processes): ports.append(start_port + i) tactic_threads = [] #start_tactic = Config.get_value("services", "tactic") #start_job_queue = Config.get_value("services", "job_queue") #start_watch_folder = Config.get_value("services", "watch_folder") start_tactic = False start_job_queue = False start_watch_folder = False start_async = False services = Config.get_value("services", "enable") custom_services = [] if services: #services = services.split("|") services = re.split("[|,]", services) for service in services: if service == 'tactic': start_tactic = True elif service == 'job_queue': start_job_queue = True elif service == 'watch_folder': start_watch_folder = True elif service == 'async': start_async = True else: custom_services.append(service) else: start_tactic = True # create a number of processes if start_tactic: self.remove_monitor_pid() #for i in range(0, self.num_processes): for port in ports: # start cherrypy tactic_thread = TacticThread(port) tactic_thread.set_dev(self.dev_mode) tactic_thread.start() tactic_threads.append(tactic_thread) time.sleep(1) #port += 1 # aSync Queue services if start_async: num_processes = Config.get_value("async", "process_count") if not num_processes: num_processes = 1 else: num_processes = int(num_processes) for i in range(0, num_processes): job_thread = ASyncThread() job_thread.start() tactic_threads.append(job_thread) # Job Queue services if start_job_queue: num_processes = Config.get_value("services", "queue_process_count") if not num_processes: num_processes = 1 else: num_processes = int(num_processes) for i in range(0, num_processes): job_thread = JobQueueThread(i) job_thread.start() tactic_threads.append(job_thread) # Watch Folder services if start_watch_folder: search = Search("sthpw/watch_folder") watch_folders = search.get_sobjects() for watch_folder in watch_folders: project_code = watch_folder.get("project_code") base_dir = watch_folder.get("base_dir") search_type = watch_folder.get("search_type") process = watch_folder.get("process") script_path = watch_folder.get("script_path") watch_folder_code = watch_folder.get("code") if not project_code: print("Watch Folder missing project_code ... skipping") continue if not base_dir: print("Watch Folder missing base_dir ... skipping") continue if not search_type: print("Watch Folder missing search_type ... skipping") continue self.watch_folder_cleanup(base_dir) watch_thread = WatchFolderThread( project_code=project_code, base_dir=base_dir, search_type=search_type, process=process, script_path=script_path, watch_folder_code=watch_folder_code) watch_thread.start() tactic_threads.append(watch_thread) # set up custom services for service in custom_services: kwargs = Config.get_section_values(service) custom_thread = CustomPythonProcessThread(**kwargs) custom_thread.start() tactic_threads.append(custom_thread) if len(tactic_threads) == 0: print("\n") print("No services started ...") print("\n") return # create a separate thread for timed processes # DEPRECATED tactic_timed_thread = TacticTimedThread() tactic_timed_thread.start() tactic_threads.append(tactic_timed_thread) # create a separate thread for scheduler processes start_scheduler = Config.get_value("services", "scheduler") if start_scheduler == 'true' or True: tactic_scheduler_thread = TacticSchedulerThread() tactic_scheduler_thread.set_dev(self.dev_mode) tactic_scheduler_thread.start() tactic_threads.append(tactic_scheduler_thread) DbContainer.close_thread_sql() self.tactic_threads = tactic_threads if self.mode == "normal": self.monitor()
def _execute(self): '''if mode is normal, this runs both the main startup (init) logic plus monitor''' from pyasm.security import Batch Batch(login_code="admin") os.environ["TACTIC_MONITOR"] = "true" if not self.num_processes: self.num_processes = Config.get_value("services", "process_count") if self.num_processes: self.num_processes = int(self.num_processes) else: self.num_processes = 3 start_port = Config.get_value("services", "start_port") ports_str = os.environ.get("TACTIC_PORTS") if not ports_str: ports_str = Config.get_value("services", "ports") if ports_str: ports = ports_str.split("|") ports = [int(x) for x in ports] else: if start_port: start_port = int(start_port) else: start_port = 8081 ports = [] for i in range(0, self.num_processes): ports.append( start_port + i ) tactic_threads = [] #start_tactic = Config.get_value("services", "tactic") #start_job_queue = Config.get_value("services", "job_queue") #start_watch_folder = Config.get_value("services", "watch_folder") start_tactic = False start_job_queue = False start_watch_folder = False start_async = False services = Config.get_value("services", "enable") custom_services = [] if services: #services = services.split("|") services = re.split("[|,]", services) for service in services: if service == 'tactic': start_tactic = True elif service == 'job_queue': start_job_queue = True elif service == 'watch_folder': start_watch_folder = True elif service == 'async': start_async = True else: custom_services.append(service) else: start_tactic = True # create a number of processes if start_tactic: self.remove_monitor_pid() #for i in range(0, self.num_processes): for port in ports: # start cherrypy tactic_thread = TacticThread(port) tactic_thread.set_dev(self.dev_mode) tactic_thread.start() tactic_threads.append(tactic_thread) time.sleep(1) #port += 1 # aSync Queue services if start_async: num_processes = Config.get_value("async", "process_count") if not num_processes: num_processes = 1 else: num_processes = int(num_processes) for i in range(0, num_processes): job_thread = ASyncThread() job_thread.start() tactic_threads.append(job_thread) # Job Queue services if start_job_queue: num_processes = Config.get_value("services", "queue_process_count") if not num_processes: num_processes = 1 else: num_processes = int(num_processes) for i in range(0, num_processes): job_thread = JobQueueThread(i) job_thread.start() tactic_threads.append(job_thread) # Watch Folder services if start_watch_folder: search = Search("sthpw/watch_folder") watch_folders = search.get_sobjects() for watch_folder in watch_folders: project_code = watch_folder.get("project_code") base_dir = watch_folder.get("base_dir") search_type = watch_folder.get("search_type") process = watch_folder.get("process") script_path = watch_folder.get("script_path") watch_folder_code = watch_folder.get("code") if not project_code: print("Watch Folder missing project_code ... skipping") continue if not base_dir: print("Watch Folder missing base_dir ... skipping") continue if not search_type: print("Watch Folder missing search_type ... skipping") continue self.watch_folder_cleanup(base_dir) watch_thread = WatchFolderThread( project_code=project_code, base_dir=base_dir, search_type=search_type, process=process, script_path = script_path, watch_folder_code=watch_folder_code ) watch_thread.start() tactic_threads.append(watch_thread) # set up custom services for service in custom_services: kwargs = Config.get_section_values(service) custom_thread = CustomPythonProcessThread(**kwargs) custom_thread.start() tactic_threads.append(custom_thread) if len(tactic_threads) == 0: print("\n") print("No services started ...") print("\n") return # create a separate thread for timed processes # DEPRECATED tactic_timed_thread = TacticTimedThread() tactic_timed_thread.start() tactic_threads.append(tactic_timed_thread) # create a separate thread for scheduler processes start_scheduler = Config.get_value("services", "scheduler") if start_scheduler == 'true' or True: tactic_scheduler_thread = TacticSchedulerThread() tactic_scheduler_thread.set_dev(self.dev_mode) tactic_scheduler_thread.start() tactic_threads.append(tactic_scheduler_thread) DbContainer.close_thread_sql() self.tactic_threads = tactic_threads if self.mode == "normal": self.monitor()
def run(my): import time time.sleep(6) #print "Starting Timed Trigger" # checks are done every 60 seconds chunk = 60 # FIXME: not sure why we have to do a batch here from pyasm.security import Batch Batch(login_code="admin") # get the all of the timed triggers #search = Search("sthpw/timed_trigger") #search.add_filter("type", "timed") search = Search("sthpw/trigger") search.add_filter("event", "timed") timed_trigger_sobjs = search.get_sobjects() timed_triggers = [] for trigger_sobj in timed_trigger_sobjs: trigger_class = trigger_sobj.get_value("class_name") try: timed_trigger = Common.create_from_class_path(trigger_class) except ImportError: raise Exception("WARNING: [%s] does not exist" % trigger_class) timed_triggers.append(timed_trigger) while 1: time.sleep(chunk) #print "Running timer" date = Date() #print "utc: ", date.get_display_time() # go through each trigger for timed_trigger in timed_triggers: print timed_trigger if not timed_trigger.is_ready(): print "... not ready" continue if timed_trigger.is_in_separate_thread(): class xxx(threading.Thread): def run(my): try: Batch() timed_trigger._do_execute() finally: DbContainer.close_thread_sql() xxx().start() else: timed_trigger._do_execute() DbContainer.close_thread_sql() if my.end: print "Stopping timed thread" break
def __init__(my, **kwargs): super(TimedTask, my).__init__(**kwargs) my.index = kwargs.get("index") my.project_code = kwargs.get("project_code") def execute(my): try: #Batch() #Command.execute_cmd(timed_trigger) Project.set_project(my.project_code) timed_triggers[my.index].execute() except Exception, e: print "Error running trigger" raise finally: DbContainer.close_thread_sql() DbContainer.commit_thread_sql() DbContainer.close_all() for idx, timed_trigger in enumerate(timed_triggers): data = timed_trigger.get_input() if not data: continue """ data = { 'type': 'interval', 'interval': 10, 'delay': 0,
def execute(my): from pyasm.security import Batch Batch(login_code="admin") os.environ["TACTIC_MONITOR"] = "true" if not my.num_processes: my.num_processes = Config.get_value("services", "process_count") if my.num_processes: my.num_processes = int(my.num_processes) else: my.num_processes = 3 start_port = Config.get_value("services", "start_port") ports_str = os.environ.get("TACTIC_PORTS") if not ports_str: ports_str = Config.get_value("services", "ports") if ports_str: ports = ports_str.split("|") ports = [int(x) for x in ports] else: if start_port: start_port = int(start_port) else: start_port = 8081 ports = [] for i in range(0, my.num_processes): ports.append(start_port + i) # create a number of processes tactic_threads = [] # for i in range(0, my.num_processes): for port in ports: # start cherrypy tactic_thread = TacticThread(port) tactic_thread.set_dev(my.dev_mode) tactic_thread.start() tactic_threads.append(tactic_thread) time.sleep(1) # port += 1 # start up scheduled triggers # from tactic.command import ScheduledTriggerMonitor # ScheduledTriggerMonitor.start() # create a separate thread for timed processes tactic_timed_thread = TacticTimedThread() tactic_timed_thread.start() tactic_threads.append(tactic_timed_thread) DbContainer.close_thread_sql() # check each thread every 20 seconds while 1: end = False try: if my.check_interval: time.sleep(my.check_interval) for tactic_thread in tactic_threads: tactic_thread.check() else: # FIXME: break for now (for windows service) break except KeyboardInterrupt, e: print "Keyboard interrupt ... exiting Tactic" for tactic_thread in tactic_threads: tactic_thread.end = True end = True if end: break
def execute(my): from pyasm.security import Batch Batch(login_code="admin") os.environ["TACTIC_MONITOR"] = "true" if not my.num_processes: my.num_processes = Config.get_value("services", "process_count") if my.num_processes: my.num_processes = int(my.num_processes) else: my.num_processes = 3 start_port = Config.get_value("services", "start_port") ports_str = os.environ.get("TACTIC_PORTS") if not ports_str: ports_str = Config.get_value("services", "ports") if ports_str: ports = ports_str.split("|") ports = [int(x) for x in ports] else: if start_port: start_port = int(start_port) else: start_port = 8081 ports = [] for i in range(0, my.num_processes): ports.append( start_port + i ) tactic_threads = [] #start_tactic = Config.get_value("services", "tactic") #start_job_queue = Config.get_value("services", "job_queue") #start_watch_folder = Config.get_value("services", "watch_folder") start_tactic = False start_job_queue = False start_watch_folder = False start_async = False services = Config.get_value("services", "enable") custom_services = [] if services: #services = services.split("|") services = re.split("[|,]", services) for service in services: if service == 'tactic': start_tactic = True elif service == 'job_queue': start_job_queue = True elif service == 'watch_folder': start_watch_folder = True elif service == 'async': start_async = True else: custom_services.append(service) else: start_tactic = True # create a number of processes if start_tactic: #for i in range(0, my.num_processes): for port in ports: # start cherrypy tactic_thread = TacticThread(port) tactic_thread.set_dev(my.dev_mode) tactic_thread.start() tactic_threads.append(tactic_thread) time.sleep(1) #port += 1 # aSync Queue services if start_async: num_processes = Config.get_value("async", "process_count") if not num_processes: num_processes = 1 else: num_processes = int(num_processes) for i in range(0, num_processes): job_thread = ASyncThread() job_thread.start() tactic_threads.append(job_thread) # Job Queue services if start_job_queue: num_processes = Config.get_value("services", "queue_process_count") if not num_processes: num_processes = 1 else: num_processes = int(num_processes) for i in range(0, num_processes): job_thread = JobQueueThread() job_thread.start() tactic_threads.append(job_thread) # Watch Folder services if start_watch_folder: search = Search("sthpw/watch_folder") watch_folders = search.get_sobjects() for watch_folder in watch_folders: project_code = watch_folder.get("project_code") base_dir = watch_folder.get("base_dir") search_type = watch_folder.get("search_type") process = watch_folder.get("process") if not project_code: print "Watch Folder missing project_code ... skipping" continue if not project_code: print "Watch Folder missing base_dir ... skipping" continue if not search_type: print "Watch Folder missing search_type ... skipping" continue watch_thread = WatchFolderThread( project_code=project_code, base_dir=base_dir, search_type=search_type, process=process ) watch_thread.start() tactic_threads.append(watch_thread) # set up custom services for service in custom_services: kwargs = Config.get_section_values(service) custom_thread = CustomPythonProcessThread(**kwargs) custom_thread.start() tactic_threads.append(custom_thread) if len(tactic_threads) == 0: print print "No services started ..." print return # create a separate thread for timed processes # DEPRECATED tactic_timed_thread = TacticTimedThread() tactic_timed_thread.start() tactic_threads.append(tactic_timed_thread) # create a separate thread for scheduler processes start_scheduler = Config.get_value("services", "scheduler") if start_scheduler == 'true': tactic_scheduler_thread = TacticSchedulerThread() tactic_scheduler_thread.start() tactic_threads.append(tactic_scheduler_thread) DbContainer.close_thread_sql() # check each thread every 20 seconds while 1: end = False try: if my.check_interval: time.sleep(my.check_interval) for tactic_thread in tactic_threads: tactic_thread._check() else: # FIXME: break for now (for windows service) break except KeyboardInterrupt, e: print "Keyboard interrupt ... exiting Tactic" for tactic_thread in tactic_threads: tactic_thread.end = True end = True if end: break
def __init__(my, **kwargs): super(TimedTask, my).__init__(**kwargs) my.index = kwargs.get("index") my.project_code = kwargs.get("project_code") def execute(my): try: #Batch() #Command.execute_cmd(timed_trigger) Project.set_project(my.project_code) timed_triggers[my.index].execute() except Exception, e: print "Error running trigger" raise finally: DbContainer.close_thread_sql() DbContainer.commit_thread_sql() DbContainer.close_all() for idx, timed_trigger in enumerate(timed_triggers): data = timed_trigger.get_input() if not data: continue """ data = { 'type': 'interval', 'interval': 10, 'delay': 0,
class CherryPyStartup(object): def __init__(my, port=''): # It is possible on startup that the database is not running. from pyasm.common import Environment from pyasm.search import DbContainer, DatabaseException, Sql plugin_dir = Environment.get_plugin_dir() sys.path.insert(0, plugin_dir) try: sql = DbContainer.get("sthpw") if sql.get_database_type() != "MongoDb": # before batch, clean up the ticket with a NULL code if os.getenv('TACTIC_MODE') != 'production': sql.do_update('DELETE from "ticket" where "code" is NULL;') else: start_port = Config.get_value("services", "start_port") if start_port: start_port = int(start_port) else: start_port = 8081 if port and int(port) == start_port: sql.do_update( 'DELETE from "ticket" where "code" is NULL;') except DatabaseException, e: # TODO: need to work on this print "ERROR: could not connect to [sthpw] database" #os.environ["TACTIC_CONFIG_PATH"] = Config.get_default_config_path() #Sql.set_default_vendor("Sqlite") Config.set_tmp_config() Config.reload_config() # try connecting again try: sql = DbContainer.get("sthpw") except: print "Could not connect to the database." raise # is it CherryPyStartup's responsibility to start batch? from pyasm.security import Batch Batch() my.site_dir = os.getenv("TACTIC_SITE_DIR") my.install_dir = os.getenv("TACTIC_INSTALL_DIR") # set up a simple environment. May need a more complex one later my.env = Environment() my.setup_env() my.config = my.setup_sites() my.init_only = False cherrypy.startup = my # this initializes the web. # - sets up virtual implied tiggers from web_init import WebInit WebInit().execute() # Windows should handle fine #start up the caching system if it's not windows cache_mode = Config.get_value("install", "cache_mode") if not cache_mode: cache_mode = 'complete' if os.name == 'nt': cache_mode = 'basic' from cache_startup import CacheStartup cmd = CacheStartup(mode=cache_mode) cmd.execute() cmd.init_scheduler() # DEPRECATED (but keeping it around" """ # start up the queue system ... if Config.get_value("sync", "enabled") == "true": # start up the sync system ... print "Starting Transaction Sync ..." from tactic.command import TransactionQueueManager TransactionQueueManager.start() # start up the sync system ... print "Starting Watch Folder Service ..." from tactic.command import WatchServerFolderTask WatchServerFolderTask.start() """ # start up scheduled triggers #from tactic.command import ScheduledTriggerMonitor #ScheduledTriggerMonitor.start() #from pyasm.web import Translation #Translation.install() # close all the threads in this startup thread from pyasm.search import DbContainer DbContainer.close_thread_sql() version = Environment.get_release_version() print print "Starting TACTIC v%s ..." % version print
def __init__(self, port=''): # It is possible on startup that the database is not running. from pyasm.common import Environment from pyasm.search import DbContainer, DatabaseException, Sql plugin_dir = Environment.get_plugin_dir() sys.path.insert(0, plugin_dir) try: sql = DbContainer.get("sthpw") if sql.get_database_type() != "MongoDb": # before batch, clean up the ticket with a NULL code if os.getenv('TACTIC_MODE') != 'production': sql.do_update('DELETE from "ticket" where "code" is NULL') else: start_port = Config.get_value("services", "start_port") if start_port: start_port = int(start_port) else: start_port = 8081 if port and int(port) == start_port: sql.do_update('DELETE from "ticket" where "code" is NULL') except DatabaseException as e: # TODO: need to work on this print("ERROR: could not connect to [sthpw] database") #os.environ["TACTIC_CONFIG_PATH"] = Config.get_default_config_path() #Sql.set_default_vendor("Sqlite") Config.set_tmp_config() Config.reload_config() # try connecting again try: sql = DbContainer.get("sthpw") except: print "Could not connect to the database." raise # is it CherryPyStartup's responsibility to start batch? from pyasm.security import Batch Batch() self.site_dir = os.getenv("TACTIC_SITE_DIR") self.install_dir = os.getenv("TACTIC_INSTALL_DIR") # set up a simple environment. May need a more complex one later self.env = Environment() self.setup_env() self.config = self.setup_sites() self.init_only = False cherrypy.startup = self # this initializes the web. # - sets up virtual implied tiggers from web_init import WebInit WebInit().execute() # Windows should handle fine #start up the caching system if it's not windows cache_mode = Config.get_value("install", "cache_mode") if not cache_mode: cache_mode = 'complete' if os.name == 'nt': cache_mode = 'basic' from cache_startup import CacheStartup cmd = CacheStartup(mode=cache_mode) cmd.execute() cmd.init_scheduler() # DEPRECATED (but keeping it around" """ # start up the queue system ... if Config.get_value("sync", "enabled") == "true": # start up the sync system ... print("Starting Transaction Sync ...") from tactic.command import TransactionQueueManager TransactionQueueManager.start() # start up the sync system ... print("Starting Watch Folder Service ...") from tactic.command import WatchServerFolderTask WatchServerFolderTask.start() """ # start up scheduled triggers #from tactic.command import ScheduledTriggerMonitor #ScheduledTriggerMonitor.start() #from pyasm.web import Translation #Translation.install() # close all the threads in this startup thread from pyasm.search import DbContainer DbContainer.close_thread_sql() version = Environment.get_release_version() print("") print("Starting TACTIC v%s ..." % version) print("")