def __init__(self, short_name, long_name, cgi_url, project_dir=None, key_dir=None, master_url=None, db_name=None, host=None, web_only=False, no_db=False, production=False ): init() self.production = production self.web_only = web_only self.no_db = no_db self.short_name = short_name self.long_name = long_name or 'Project ' + self.short_name.replace('_',' ').capitalize() self.project_dir = project_dir or os.path.join(options.projects_dir, self.short_name) self.config = configxml.ConfigFile(self.dir('config.xml')).init_empty() config = self.config.config # this is where default project config is defined config.long_name = self.long_name config.db_user = options.db_user config.db_name = db_name or options.user_name + '_' + self.short_name config.db_passwd = options.db_passwd config.db_host = options.db_host config.shmem_key = generate_shmem_key() config.uldl_dir_fanout = 1024 config.host = host config.min_sendwork_interval = 0 config.max_wus_to_send = 50 config.daily_result_quota = 500 config.disable_account_creation = 0 config.show_results = 1 config.cache_md5_info = 1 config.sched_debug_level = 3 config.fuh_debug_level = 3 config.one_result_per_user_per_wu = 0 config.send_result_abort = 1 config.dont_generate_upload_certificates = 1 config.ignore_upload_certificates = 1 if web_only: config.no_computing = 1 config.master_url = master_url or os.path.join(options.html_url , self.short_name , '') config.download_url = os.path.join(config.master_url, 'download') config.upload_url = os.path.join(cgi_url , 'file_upload_handler') config.download_dir = os.path.join(self.project_dir , 'download') config.upload_dir = os.path.join(self.project_dir , 'upload') config.key_dir = key_dir or os.path.join(self.project_dir , 'keys') config.app_dir = os.path.join(self.project_dir, 'apps') config.log_dir = self.project_dir+'log_'+config.host if production: config.min_sendwork_interval = 6 self.scheduler_url = os.path.join(cgi_url , 'cgi')
def setup_config(task_path): """Adds appropriate daemons to the BOINC config.xml file. """ logging.info("Adding PyMW Assimilator daemon to config.xml") config = configxml.ConfigFile().read() # Append new instance of pymw_assimilator to config.xml asm = "pymw_assimilator.py -d 3 -app pymw -pymw_dir " + task_path add_daemon(config, asm, "pymw_assimilator") # add a file deleter, ignoring batches asm = "file_deleter -d 3 -dont_delete_batches" add_daemon(config, asm, "file_deleter") # add a default validator asm = "sample_trivial_validator -d 3 -app pymw" add_daemon(config, asm, "sample_trivial_validator") # add a feeder and a transitioner asm = "feeder -d 3 -random_order" add_daemon(config, asm, "feeder") asm = "transitioner -d 3" add_daemon(config, asm, "transitioner") return config
def main(): args = parse_args() if not os.path.isfile('project.xml'): print('Must be run from the project directory') sys.exit(1) hostname = socket.gethostname().split('.')[0] lockfile_name = os.path.join('pid_{}'.format(hostname), 'add_target.lock') try: lock_file(lockfile_name) except IOError: print('Another {} process is running, please try again'.format( sys.argv[0])) project_file = projectxml.ProjectFile('project.xml').read() config_file = configxml.ConfigFile('config.xml').read() name = args.app platforms = args.platforms for platform in platforms: # Add name_platform to apps in project.xml add_app(project_file, name, platform) # Create app directory with wrapper, version.xml create_app_dir(name, platform) create_app_templates(name, platform) add_daemons(config_file, name, platform) project_file.write() config_file.write() os.unlink(lockfile_name) # Update db from project file subprocess.check_call(['bin/xadd']) # Restart project subprocess.check_call(['bin/stop']) subprocess.check_call(['bin/start']) print('New app versions installed into apps/{}_*. Make any changes you ' 'need, then run bin/update_versions to install them.'.format(name))
if args['limit'] is not None: LIMIT = args['limit'] # The BOINC scripts/apps do not feel at home outside their directory os.chdir(POGS_BOINC_PROJECT_ROOT) # Connect to the database - the login string is set in the database package ENGINE = create_engine(DB_LOGIN) connection = ENGINE.connect() if count is not None and count >= WG_THRESHOLD: LOG.info('Nothing to do') else: # Get the BOINC downloads and fanout values boinc_config = configxml.ConfigFile().read() download_dir = boinc_config.config.download_dir fanout = long(boinc_config.config.uldl_dir_fanout) LOG.info("download_dir: %s, fanout: %d", download_dir, fanout) # Open the BOINC DB LOG.info("Opening BOINC DB") return_value = py_boinc.boinc_db_open() if return_value != 0: LOG.error('Could not open BOINC DB return code: %d', return_value) else: # Normal operation total_work_units_added = 0 work_units_to_be_added = WG_THRESHOLD - count + WG_HIGH_WATER_MARK
print "Setting project URL to: "+URL_BASE for filename in ["config.xml","html/user/schedulers.txt","boincserver.readme"]: filepath = join(PROJHOME,filename) if exists(filepath): with open(filepath,"r") as f: contents = f.read() with open(filepath,"w") as f: f.write(contents.replace("http://url_base/",URL_BASE)) if not '--copy-only' in sys.argv: print "Creating database..." waited=False while True: try: database.create_database(srcdir='/root/boinc', config=configxml.ConfigFile(filename=join(PROJHOME,'config.xml')).read().config, drop_first=False) except _mysql_exceptions.ProgrammingError as e: if e[0]==1007: print "Database exists, not overwriting." break else: raise except _mysql_exceptions.OperationalError as e: if e[0]==2003: if waited: sys.stdout.write('.'); sys.stdout.flush() else: sys.stdout.write("Waiting for mysql server to start..."); sys.stdout.flush() waited=True sleep(1) else:
for x in ['html', 'html/cache', 'upload', 'log_cosmohome']: sh('chmod -R g+w /root/projects/cosmohome/'+x) print "Linking httpd.conf..." conf_file = '/root/projects/cosmohome/cosmohome.httpd.conf' sym_target = osp.join("/etc/apache2/sites-enabled/",osp.basename(conf_file)) if not osp.exists(sym_target): os.symlink(os.path.abspath(conf_file),sym_target) if not '--copy-only' in sys.argv: print "Creating database..." try: database.create_database( srcdir = '/root/boinc', config = configxml.ConfigFile(filename='/root/projects/cosmohome/config.xml').read().config, drop_first = False ) except _mysql_exceptions.ProgrammingError as e: if e[0]==1007: print "Database exists, not overwriting." else: raise else: sh('cd /root/projects/cosmohome/html/ops; ./db_schemaversion.php > /root/projects/cosmohome/db_revision') print "Running BOINC update scripts..." os.chdir('/root/projects/cosmohome') sh('bin/xadd') sh('(%s) | bin/update_versions'%('; '.join(['echo y']*10)))