def start_ss_cron_job(sync_time, use_json=False): from shadowsocks.mdb.models import User, UserServer loop = asyncio.get_event_loop() try: if use_json: User.create_or_update_from_json("userconfigs.json") else: User.create_or_update_from_remote() UserServer.flush_data_to_remote() User.init_user_servers() except Exception as e: logging.warning(f"sync user error {e}") loop.call_later(sync_time, start_ss_cron_job, sync_time, use_json)
async def start_ss_json_server(self): User.create_or_update_from_json("userconfigs.json") for user in User.select().where(User.enable == True): await self.loop.create_task(self.init_server(user))
async def sync_from_json_cron(self, sync_time): try: User.create_or_update_from_json("userconfigs.json") except Exception as e: logging.warning(f"sync user from json error {e}")