def __call__(self, app, watch, *args, **kwds): if not watch: return Server.__call__(self, app=app, *args, **kwds) if sys.platform != "win32": # Start webpack in the static/ directories if it's configured static_dir_paths = [app.static_folder] if 'WHYIS_CDN_DIR' in app.config and app.config['WHYIS_CDN_DIR'] is not None: static_dir_paths.append(app.config["WHYIS_CDN_DIR"]) webpack_static_dir_paths = [] for static_dir_path in static_dir_paths: if not os.path.isfile(os.path.join(static_dir_path, "package.json")): continue if not os.path.isfile(os.path.join(static_dir_path, "webpack.config.js")): continue if not os.path.isdir(os.path.join(static_dir_path, "node_modules")): print("%s has a package.json but no node_modules; need to run 'npm install' to get webpack?", file=sys.stderr) continue webpack_static_dir_paths.append(static_dir_path) else: webpack_static_dir_paths = [] for static_dir_path in webpack_static_dir_paths: subprocess.call(["npm", "install"], cwd=static_dir_path) class CleanChildProcesses: def __enter__(self): os.setpgrp() # create new process group, become its leader def __exit__(self, type, value, traceback): try: import signal os.killpg(0, signal.SIGINT) # kill all processes in my group except KeyboardInterrupt: # SIGINT is delievered to this process as well as the child processes. # Ignore it so that the existing exception, if any, is returned. This # leaves us with a clean exit code if there was no exception. pass with CleanChildProcesses(): for static_dir_path in webpack_static_dir_paths: subprocess.Popen(["npm", "start"], cwd=static_dir_path) Server.__call__(self, app=app, *args, **kwds)
def __call__(self, app, *args, **kwargs): with create_app().app_context(): query = db.session.query(Role).all() if not query: db.session.add(Role(role_name="superuser")) db.session.add(Role(role_name="user")) db.session.commit() print("Roles have been created.") return Server.__call__(self, app, *args, **kwargs)
def __call__(self, app): server_args = { 'processes': 1, 'threaded': False, 'use_debugger': True, 'use_reloader': self.with_reloader, 'host': self.host, 'passthrough_errors': False, 'port': self.port } webbrowser.open('http://%s:%s/' % (self.host, self.port)) app.host, app.port, app.site, app.use_cache = self.host, self.port, \ self.site, self.use_cache if self.use_cache: app.cache = CustomDummyCache() return Server.__call__(self, app, **server_args)
def __call__(self, app, *args, **kwargs): return Server.__call__(self, app, *args, **kwargs)
def __call__(self, app, *args, **kwargs): self.init() return Server.__call__(self, app, *args, **kwargs)
def __call__(self, app, *args, **kwargs): _run_on_start() # Hint: Here you could manipulate app return Server.__call__(self, app, *args, **kwargs)
def __call__(self, app, *args, **kwargs): connect() return Server.__call__(self, app, *args, **kwargs)
def __call__(self, app, *args, **kwargs): order_Scheduler() return Server.__call__(self, app, *args, **kwargs)
def __call__(self, app, *args, **kwargs): issuer.startup_init(ENV) #Hint: Here you could manipulate app return Server.__call__(self, app, *args, **kwargs)
def __call__(self, app, *args, **kwargs): load_all_configs() return Server.__call__(self, app, *args, **kwargs)
def __call__(self, app, *args, **kwargs): scheduler.start() #Hint: Here you could manipulate app return Server.__call__(self, app, *args, **kwargs)
def __call__(self, app, *args, **kwargs): custom_call() return Server.__call__(self, app, *args, **kwargs)