示例#1
0
void service::recreate(bool updating)
{
   if (updating)
      utils_docker::pullImage(mParams, mSettings, getImageName());
   
   try
   {
      // nuke any existing dService files on host (but preserve volume containers!).
      if (utils::fileexists(getPath()))
         utils::deltree(getPath(), mParams);

      // notice for hostVolumes.
      if (utils::fileexists(getPathHostVolume()))
         logmsg(kLINFO, "A drunner hostVolume already exists for " + getName() + ", reusing it.");

      // create the basic directories.
      ensureDirectoriesExist();

      // copy files to service directory on host.
      std::string op;
      int r = utils::bashcommand("docker run --rm -i -v " +
         getPathdRunner() + ":/tempcopy " + getImageName() + " /bin/bash -c \"cp -r /drunner/* /tempcopy/ && chmod a+rx /tempcopy/*\"", op);
      if (r != 0)
         logmsg(kLERROR, "Couldn't copy the service files. You will need to reinstall the service.");

      // write out variables.sh for the dService.
      drunnerCompose drc(*this, mParams);
      if (drc.readOkay()==kRError)
         fatal("Unexpected error - docker-compose.yml is broken.");
      
      // write out servicevars.sh for ourselves.
      sh_servicevars svcvars(getPath());
      svcvars.create(getImageName());
      if (!svcvars.write())
         fatal("Unexpected error - couldn't write out servicevars.sh.");

      // make sure we have the latest of all exra containers.
      for (const auto & entry : drc.getServicesInfo())
         if (entry.mImageName != getImageName()) // don't pull main image again.
            utils_docker::pullImage(mParams, mSettings, entry.mImageName);

      // create the utils.sh file for the dService.
      generate_utils_sh(getPathdRunner(), mParams);

      // create launch script
      createLaunchScript();

      // create volumes
      createVolumes(&drc);
   }

   catch (const eExit & e) {
      // tidy up.
      if (utils::fileexists(getPath()))
         utils::deltree(getPath(), mParams);

      throw (e);
   }
}
void
IpodCollectionLocation::copyUrlsToCollection( const QMap<Meta::TrackPtr,KUrl> &sources,
                                              const Transcoding::Configuration &configuration )
{
    if( !isWritable() )
        return;  // mostly unreachable, CollectionLocation already checks this and issues a warning
    ensureDirectoriesExist();

    IpodCopyTracksJob *job = new IpodCopyTracksJob( sources, m_coll, configuration, isGoingToRemoveSources() );
    int trackCount = sources.size();
    Amarok::Components::logger()->newProgressOperation( job,
        operationInProgressText( configuration, trackCount ), trackCount, job, SLOT(abort()) );

    qRegisterMetaType<IpodCopyTracksJob::CopiedStatus>( "IpodCopyTracksJob::CopiedStatus" );
    connect( job, SIGNAL(signalTrackProcessed(Meta::TrackPtr,Meta::TrackPtr,IpodCopyTracksJob::CopiedStatus)),
             this, SLOT(slotCopyTrackProcessed(Meta::TrackPtr,Meta::TrackPtr,IpodCopyTracksJob::CopiedStatus)) );
    connect( job, SIGNAL(done(ThreadWeaver::Job*)), this, SLOT(slotCopyOperationFinished()) );
    connect( job, SIGNAL(done(ThreadWeaver::Job*)), job, SLOT(deleteLater()) );
    ThreadWeaver::Weaver::instance()->enqueue( job );
}