def __init__(my, port=''): # It is possible on startup that the database is not running. from pyasm.search import DbContainer, DatabaseException, Sql 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
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("")
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("")