com.anrisoftware.sscontrol.httpd.redmine.thin.AbstractThinConfig.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sscontrol-httpd-redmine Show documentation
Show all versions of sscontrol-httpd-redmine Show documentation
Redmine project management web application - http://www.redmine.org/
/*
* Copyright ${project.inceptionYear] Erwin Müller
*
* This file is part of sscontrol-httpd-redmine.
*
* sscontrol-httpd-redmine is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* sscontrol-httpd-redmine is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
* for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with sscontrol-httpd-redmine. If not, see .
*/
package com.anrisoftware.sscontrol.httpd.redmine.thin
import groovy.util.logging.Slf4j
import org.apache.commons.lang3.builder.ToStringBuilder
import org.joda.time.Duration
import org.stringtemplate.v4.ST
import com.anrisoftware.propertiesutils.ContextProperties
import com.anrisoftware.sscontrol.httpd.domain.Domain
import com.anrisoftware.sscontrol.httpd.redmine.RedmineService
import com.anrisoftware.sscontrol.httpd.redmine.nginx_thin_ubuntu_12_04.RedmineConfigFactory
import com.anrisoftware.sscontrol.httpd.webservice.WebService
/**
* Thin Redmine service configuration.
*
* @author Erwin Mueller, [email protected]
* @since 1.0
*/
@Slf4j
abstract class AbstractThinConfig {
/**
* @see ServiceConfig#getScript()
*/
Object script
/**
* @see ServiceConfig#deployDomain(Domain, Domain, WebService, List)
*/
abstract void deployDomain(Domain domain, Domain refDomain, WebService service, List config)
/**
* @see ServiceConfig#deployService(Domain, WebService, List)
*/
abstract void deployService(Domain domain, WebService service, List config)
/**
* Returns the Thin service chdir directory, for
* example {@code "/var/www/domain.com/redmineprefix".}
*
* @param domain
* the {@link Domain}.
*
* @param service
* the {@link RedmineService}.
*/
File domainChdirDir(Domain domain, RedmineService service) {
def name = profileProperty "redmine_thin_domain_configuration_file", thinProperties
def domainName = domainNameAsFileName domain
def file = new ST(name).add("domainName", domainName).add("servicePrefix", service.prefix).render()
new File(confDir, file)
}
/**
* Returns the Thin service configuration file, for
* example {@code "/etc/thin1.8/_.yml".}
*
* @param domain
* the {@link Domain}.
*
* @param service
* the {@link RedmineService}.
*
*
* - profile property {@code "redmine_thin_domain_configuration_file"}
*
*
* @see #getThinConfDir()
*/
File domainConfigurationFile(Domain domain, RedmineService service) {
def name = profileProperty "redmine_thin_domain_configuration_file", thinProperties
def domainName = domainNameAsFileName domain
def file = new ST(name).add("domainName", domainName).add("servicePrefix", service.prefix).render()
new File(confDir, file)
}
/**
* Returns the Thin service log file, for
* example {@code "/var/log/thin/_.log".}
*
* @param domain
* the {@link Domain}.
*
* @param service
* the {@link RedmineService}.
*
*
* - profile property {@code "redmine_thin_domain_log_file"}
*
*
* @see #getThinLogDir()
*/
File domainLogFile(Domain domain, RedmineService service) {
def name = profileProperty "redmine_thin_domain_log_file", thinProperties
def domainName = domainNameAsFileName domain
def file = new ST(name).add("domainName", domainName).add("servicePrefix", service.prefix).render()
new File(logDir, file)
}
/**
* Returns the Thin service pid file, for
* example {@code "/var/run/thin/_.pid".}
*
* @param domain
* the {@link Domain}.
*
* @param service
* the {@link RedmineService}.
*
*
* - profile property {@code "redmine_thin_domain_pid_file"}
*
*
* @see #getThinRunDir()
*/
File domainPidFile(Domain domain, RedmineService service) {
def name = profileProperty "redmine_thin_domain_pid_file", thinProperties
def domainName = domainNameAsFileName domain
def file = new ST(name).add("domainName", domainName).add("servicePrefix", service.prefix).render()
new File(runDir, file)
}
/**
* Returns the Thin service socket file, for
* example {@code "/var/run/thin/_.sock".}
*
* @param domain
* the {@link Domain}.
*
* @param service
* the {@link RedmineService}.
*
*
* - profile property {@code "redmine_thin_domain_socket_file"}
*
*
* @see #getThinRunDir()
*/
File domainSocketFile(Domain domain, RedmineService service) {
def name = profileProperty "redmine_thin_domain_socket_file", thinProperties
def domainName = domainNameAsFileName domain
def file = new ST(name).add("domainName", domainName).add("servicePrefix", service.prefix).render()
new File(runDir, file)
}
/**
* Returns the thin command, for example {@code "/usr/bin/thin".}
*
*
* - profile property {@code "redmine_thin_command"}
*
*/
String getThinCommand() {
profileProperty "redmine_thin_command", thinProperties
}
/**
* Returns the thin command, for
* example {@code "/etc/init.d/thin restart".}
*
*
* - profile property {@code "redmine_thin_restart_command"}
*
*/
String getThinRestartCommand() {
profileProperty "redmine_thin_restart_command", thinProperties
}
/**
* Returns the thin command, for
* example {@code "".}
*
*
* - profile property {@code "redmine_thin_restart_services"}
*
*/
List getThinRestartServices() {
profileListProperty "redmine_thin_restart_services", thinProperties
}
/**
* Returns the Thin script, for example {@code "/etc/init.d/thin".}
*
*
* - profile property {@code "redmine_thin_script_file"}
*
*/
File getThinScriptFile() {
profileProperty("redmine_thin_script_file", thinProperties) as File
}
/**
* Returns the Thin defaults file, for
* example {@code "/etc/default/thin".}
*
*
* - profile property {@code "redmine_thin_defaults_file"}
*
*/
File getThinDefaultsFile() {
profileProperty("redmine_thin_defaults_file", thinProperties) as File
}
/**
* Returns the Thin configuration directory, for
* example {@code "/etc/thin1.8".}
*
*
* - profile property {@code "redmine_thin_configuration_directory"}
*
*/
File getConfDir() {
profileProperty("redmine_thin_configuration_directory", thinProperties) as File
}
/**
* Returns the Thin log directory, for
* example {@code "/var/log/thin".}
*
*
* - profile property {@code "redmine_thin_log_directory"}
*
*/
File getLogDir() {
profileProperty("redmine_thin_log_directory", thinProperties) as File
}
/**
* Returns the Thin run directory, for
* example {@code "/var/run/thin".}
*
*
* - profile property {@code "redmine_thin_run_directory"}
*
*/
File getRunDir() {
profileProperty("redmine_thin_run_directory", thinProperties) as File
}
/**
* Returns the Thin user, for
* example {@code "thin".}
*
*
* - profile property {@code "redmine_thin_user"}
*
*/
String getThinUser() {
profileProperty "redmine_thin_user", thinProperties
}
/**
* Returns the Thin user group, for
* example {@code "thin".}
*
*
* - profile property {@code "redmine_thin_group"}
*
*/
String getThinGroup() {
profileProperty "redmine_thin_group", thinProperties
}
/**
* Returns the Thin timeout duration, for
* example {@code "PT30S".}
*
*
* - profile property {@code "redmine_thin_timeout_duration"}
*
*/
Duration getTimeoutDuration() {
profileDurationProperty "redmine_thin_timeout_duration", thinProperties
}
/**
* Returns the Thin default maximum connections, for
* example {@code "1024".}
*
*
* - profile property {@code "redmine_thin_max_connections"}
*
*/
int getMaxConnections() {
profileNumberProperty "redmine_thin_max_connections", thinProperties
}
/**
* Returns the Thin default maximum persistent connections, for
* example {@code "512".}
*
*
* - profile property {@code "redmine_thin_max_persistent_connections"}
*
*/
int getMaxPersistentConnections() {
profileNumberProperty "redmine_thin_max_persistent_connections", thinProperties
}
/**
* Returns the Thin default wait duration, for
* example {@code "PT30S".}
*
*
* - profile property {@code "redmine_thin_wait_duration"}
*
*/
Duration getWaitDuration() {
profileDurationProperty "redmine_thin_wait_duration", thinProperties
}
/**
* Returns the Thin default servers count, for
* example {@code "1".}
*
*
* - profile property {@code "redmine_thin_servers_count"}
*
*/
int getServersCount() {
profileNumberProperty "redmine_thin_servers_count", thinProperties
}
/**
* Returns the Redmine service name.
*/
String getServiceName() {
RedmineConfigFactory.WEB_NAME
}
/**
* Returns the Thin properties.
*
* @return the {@link ContextProperties} properties.
*/
abstract ContextProperties getThinProperties()
/**
* Returns the profile name.
*/
abstract String getProfile()
/**
* @see ServiceConfig#setScript(LinuxScript)
*/
void setScript(Object script) {
this.script = script
}
/**
* Delegates missing properties to {@link LinuxScript}.
*/
def propertyMissing(String name) {
script.getProperty name
}
/**
* Delegates missing methods to {@link LinuxScript}.
*/
def methodMissing(String name, def args) {
script.invokeMethod name, args
}
@Override
public String toString() {
new ToStringBuilder(this)
.append("service name", getServiceName())
.append("profile name", getProfile()).toString();
}
}