| | |
| | | import com.gitblit.utils.IdGenerator; |
| | | import com.gitblit.utils.StringUtils; |
| | | import com.gitblit.utils.TimeUtils; |
| | | import com.gitblit.utils.WorkQueue; |
| | | |
| | | /** |
| | | * Services manager manages long-running services/processes that either have no |
| | |
| | | |
| | | private final IGitblit gitblit; |
| | | |
| | | private final IdGenerator idGenerator; |
| | | |
| | | private final WorkQueue workQueue; |
| | | |
| | | private FanoutService fanoutService; |
| | | |
| | | private GitDaemon gitDaemon; |
| | |
| | | public ServicesManager(IGitblit gitblit) { |
| | | this.settings = gitblit.getSettings(); |
| | | this.gitblit = gitblit; |
| | | int defaultThreadPoolSize = settings.getInteger(Keys.execution.defaultThreadPoolSize, 1); |
| | | this.idGenerator = new IdGenerator(); |
| | | this.workQueue = new WorkQueue(idGenerator, defaultThreadPoolSize); |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (sshDaemon != null) { |
| | | sshDaemon.stop(); |
| | | } |
| | | workQueue.stop(); |
| | | return this; |
| | | } |
| | | |
| | | public boolean isServingRepositories() { |
| | | return isServingHTTP() |
| | | || isServingGIT() |
| | | || isServingSSH(); |
| | | } |
| | | |
| | | public boolean isServingHTTP() { |
| | | return settings.getBoolean(Keys.git.enableGitServlet, true); |
| | | } |
| | | |
| | | public boolean isServingGIT() { |
| | | return gitDaemon != null && gitDaemon.isRunning(); |
| | | } |
| | | |
| | | public boolean isServingSSH() { |
| | | return sshDaemon != null && sshDaemon.isRunning(); |
| | | } |
| | | |
| | | protected void configureFederation() { |
| | |
| | | String bindInterface = settings.getString(Keys.git.sshBindInterface, "localhost"); |
| | | if (port > 0) { |
| | | try { |
| | | sshDaemon = new SshDaemon(gitblit, new IdGenerator()); |
| | | sshDaemon = new SshDaemon(gitblit, workQueue); |
| | | sshDaemon.start(); |
| | | } catch (IOException e) { |
| | | sshDaemon = null; |
| | |
| | | } |
| | | |
| | | public String getSshDaemonUrl(HttpServletRequest request, UserModel user, RepositoryModel repository) { |
| | | if (user == null || UserModel.ANONYMOUS.equals(user)) { |
| | | // SSH always requires authentication - anonymous access prohibited |
| | | return null; |
| | | } |
| | | if (sshDaemon != null) { |
| | | String bindInterface = settings.getString(Keys.git.sshBindInterface, "localhost"); |
| | | if (bindInterface.equals("localhost") |
| | |
| | | @Override |
| | | public void reschedule(FederationModel registration) { |
| | | // schedule the next pull |
| | | int mins = TimeUtils.convertFrequencyToMinutes(registration.frequency); |
| | | int mins = TimeUtils.convertFrequencyToMinutes(registration.frequency, 5); |
| | | registration.nextPull = new Date(System.currentTimeMillis() + (mins * 60 * 1000L)); |
| | | scheduledExecutor.schedule(new FederationPuller(registration), mins, TimeUnit.MINUTES); |
| | | logger.info(MessageFormat.format( |