Add fcron, some formatting fixes

This commit is contained in:
Sander van der Burg 2021-02-23 21:49:52 +01:00 committed by Sander van der Burg
parent 3f11dbfd4f
commit 9d73efd995
17 changed files with 175 additions and 30 deletions

View File

@ -2,12 +2,13 @@
"ids" = {
"gids" = {
"apache" = 2000;
"influxdb" = 2001;
"mongodb" = 2002;
"mysql" = 2003;
"postgresql" = 2004;
"sshd" = 2005;
"tomcat" = 2006;
"fcron" = 2001;
"influxdb" = 2002;
"mongodb" = 2003;
"mysql" = 2004;
"openssh" = 2005;
"postgresql" = 2006;
"tomcat" = 2007;
};
"httpPorts" = {
"apache" = 8080;
@ -32,7 +33,7 @@
"postgresql" = 5432;
};
"sshPorts" = {
"sshd" = 1222;
"openssh" = 1222;
};
"svnPorts" = {
"svnserve" = 3690;
@ -45,16 +46,17 @@
};
"uids" = {
"apache" = 2000;
"influxdb" = 2001;
"mongodb" = 2002;
"mysql" = 2003;
"postgresql" = 2004;
"sshd" = 2005;
"tomcat" = 2006;
"fcron" = 2001;
"influxdb" = 2002;
"mongodb" = 2003;
"mysql" = 2004;
"openssh" = 2005;
"postgresql" = 2006;
"tomcat" = 2007;
};
};
"lastAssignments" = {
"gids" = 2006;
"gids" = 2007;
"httpPorts" = 8081;
"httpsPorts" = 8443;
"inetHTTPPorts" = 9001;
@ -66,6 +68,6 @@
"svnPorts" = 3690;
"tomcatAJPPorts" = 8009;
"tomcatServerPorts" = 8005;
"uids" = 2006;
"uids" = 2007;
};
}

View File

@ -3,6 +3,7 @@
, stateDir ? "/var"
, runtimeDir ? "${stateDir}/run"
, logDir ? "${stateDir}/log"
, spoolDir ? "${stateDir}/spool"
, cacheDir ? "${stateDir}/cache"
, tmpDir ? (if stateDir == "/var" then "/tmp" else "${stateDir}/tmp")
, forceDisableUserChange ? false
@ -13,7 +14,7 @@ let
ids = if builtins.pathExists ./ids.nix then (import ./ids.nix).ids else {};
constructors = import ../../services-agnostic/constructors.nix {
inherit pkgs stateDir runtimeDir logDir tmpDir cacheDir forceDisableUserChange processManager ids;
inherit pkgs stateDir runtimeDir logDir tmpDir cacheDir spoolDir forceDisableUserChange processManager ids;
};
in
rec {
@ -117,4 +118,10 @@ rec {
docker = {
pkg = constructors.docker;
};
fcron = {
pkg = constructors.fcron {};
requiresUniqueIdsFor = [ "uids" "gids" ];
};
}

View File

@ -1,5 +1,14 @@
{createManagedProcess, stdenv, tomcat, jre, stateDir, runtimeDir, tmpDir, forceDisableUserChange}:
{instanceSuffix ? "", instanceName ? "tomcat${instanceSuffix}", serverPort ? 8005, httpPort ? 8080, httpsPort ? 8443, ajpPort ? 8009, commonLibs ? [], postInstall ? ""}:
{ instanceSuffix ? ""
, instanceName ? "tomcat${instanceSuffix}"
, serverPort ? 8005
, httpPort ? 8080
, httpsPort ? 8443
, ajpPort ? 8009
, commonLibs ? []
, postInstall ? ""
}:
let
tomcatConfigFiles = stdenv.mkDerivation {

View File

@ -4,6 +4,7 @@
, logDir
, runtimeDir
, cacheDir
, spoolDir
, tmpDir
, forceDisableUserChange
, processManager
@ -50,6 +51,11 @@ in
inherit (pkgs) docker kmod;
};
fcron = import ./fcron {
inherit createManagedProcess stateDir spoolDir runtimeDir tmpDir forceDisableUserChange;
inherit (pkgs) writeTextFile fcron;
};
hydra-evaluator = import ./hydra/hydra-evaluator.nix {
inherit createManagedProcess;
hydra = pkgs.hydra-unstable;

View File

@ -0,0 +1,52 @@
{createManagedProcess, writeTextFile, fcron, stateDir, runtimeDir, tmpDir, spoolDir, forceDisableUserChange}:
{instanceSuffix ? "", instanceName ? "fcron${instanceSuffix}"}:
let
fcronSpoolDir = "${spoolDir}/${instanceName}";
fcronRuntimeDir = if forceDisableUserChange then tmpDir else runtimeDir;
fcronEtcDir = "${stateDir}/etc/${instanceName}";
configFile = writeTextFile {
name = "fcron.conf";
text = ''
fcrontabs=${fcronSpoolDir}
pidfile=${fcronRuntimeDir}/${instanceName}.pid
suspendfile=${fcronRuntimeDir}/${instanceName}.suspend
fifofile=${fcronRuntimeDir}/${instanceName}.fifo
fcronallow=${fcronEtcDir}/fcron.allow
fcrondeny=${fcronEtcDir}/fcron.deny
'';
};
user = instanceName;
group = instanceName;
in
createManagedProcess {
name = instanceName;
inherit instanceName;
initialize = ''
mkdir -p ${fcronSpoolDir}
'';
process = "${fcron}/bin/fcron";
args = [ "--configfile" configFile ];
foregroundProcessExtraArgs = [ "--foreground" "--nosyslog" ];
daemonExtraArgs = [ "--background" ];
credentials = {
groups = {
"${group}" = {};
};
users = {
"${user}" = {
inherit group;
description = "Fcron user";
};
};
};
overrides = {
sysvinit = {
runlevels = [ 2 3 4 5 ];
};
};
}

View File

@ -1,5 +1,10 @@
{createManagedProcess, influxdb, stateDir}:
{instanceSuffix ? "", instanceName ? "influxdb${instanceSuffix}", configFile, postInstall ? ""}:
{ instanceSuffix ? ""
, instanceName ? "influxdb${instanceSuffix}"
, configFile
, postInstall ? ""
}:
let
user = instanceName;

View File

@ -1,5 +1,11 @@
{createManagedProcess, mongodb, runtimeDir}:
{instanceSuffix ? "", instanceName ? "mongodb${instanceSuffix}", configFile, initialize ? "", postInstall ? ""}:
{ instanceSuffix ? ""
, instanceName ? "mongodb${instanceSuffix}"
, configFile
, initialize ? ""
, postInstall ? ""
}:
let
user = instanceName;

View File

@ -1,5 +1,11 @@
{createManagedProcess, stdenv, writeTextFile, mongodb, runtimeDir, stateDir, forceDisableUserChange}:
{instanceSuffix ? "", instanceName ? "mongodb${instanceSuffix}", bindIP ? "127.0.0.1", port ? 27017, postInstall ? ""}:
{ instanceSuffix ? ""
, instanceName ? "mongodb${instanceSuffix}"
, bindIP ? "127.0.0.1"
, port ? 27017
, postInstall ? ""
}:
let
mongodbDir = "${stateDir}/db/${instanceName}";

View File

@ -1,5 +1,10 @@
{createManagedProcess, stdenv, mysql, stateDir, runtimeDir, forceDisableUserChange}:
{port ? 3306, instanceSuffix ? "", instanceName ? "mysql${instanceSuffix}", postInstall ? ""}:
{ port ? 3306
, instanceSuffix ? ""
, instanceName ? "mysql${instanceSuffix}"
, postInstall ? ""
}:
let
dataDir = "${stateDir}/db/${instanceName}";

View File

@ -1,5 +1,10 @@
{createManagedProcess, stdenv, nginx, stateDir, runtimeDir, cacheDir, forceDisableUserChange}:
{configFile, dependencies ? [], instanceSuffix ? "", instanceName ? "nginx${instanceSuffix}"}:
{ configFile
, dependencies ? []
, instanceSuffix ? ""
, instanceName ? "nginx${instanceSuffix}"
}:
let
user = instanceName;

View File

@ -1,5 +1,11 @@
{createManagedProcess, stdenv, writeTextFile, nginx, runtimeDir, stateDir, cacheDir, forceDisableUserChange}:
{port ? 80, webapps ? [], instanceSuffix ? "", instanceName ? "nginx${instanceSuffix}"}:
{ port ? 80
, webapps ? []
, instanceSuffix ? ""
, instanceName ? "nginx${instanceSuffix}"
}:
interDependencies:
let

View File

@ -1,5 +1,12 @@
{createManagedProcess, stdenv, writeTextFile, nginx, runtimeDir, stateDir, cacheDir, forceDisableUserChange}:
{port ? 80, webapps ? [], instanceSuffix ? "", instanceName ? "nginx${instanceSuffix}", enableCache ? false}:
{ port ? 80
, webapps ? []
, instanceSuffix ? ""
, instanceName ? "nginx${instanceSuffix}"
, enableCache ? false
}:
interDependencies:
let

View File

@ -1,5 +1,10 @@
{createManagedProcess, writeTextFile, openssh, stateDir, runtimeDir, tmpDir, forceDisableUserChange}:
{instanceSuffix ? "", instanceName ? "sshd${instanceSuffix}", port ? 22, extraSSHDConfig ? ""}:
{ instanceSuffix ? ""
, instanceName ? "sshd${instanceSuffix}"
, port ? 22
, extraSSHDConfig ? ""
}:
let
sshdStateDir = "${stateDir}/lib/${instanceName}";

View File

@ -1,5 +1,11 @@
{createManagedProcess, stdenv, postgresql, su, stateDir, runtimeDir, forceDisableUserChange}:
{port ? 5432, instanceSuffix ? "", instanceName ? "postgresql${instanceSuffix}", configFile ? null, postInstall ? ""}:
{ port ? 5432
, instanceSuffix ? ""
, instanceName ? "postgresql${instanceSuffix}"
, configFile ? null
, postInstall ? ""
}:
let
postgresqlStateDir = "${stateDir}/db/${instanceName}";

View File

@ -1,5 +1,11 @@
{createManagedProcess, supervisor, runtimeDir, logDir}:
{instanceSuffix ? "", instanceName ? "supervisord${instanceSuffix}", initialize ? "", configFile, postInstall ? ""}:
{ instanceSuffix ? ""
, instanceName ? "supervisord${instanceSuffix}"
, initialize ? ""
, configFile
, postInstall ? ""
}:
let
pidFile = "${runtimeDir}/${instanceName}.pid";
@ -18,7 +24,7 @@ createManagedProcess {
overrides = {
sysvinit = {
runlevels = [ 3 4 5 ];
runlevels = [ 2 3 4 5 ];
};
};
}

View File

@ -1,5 +1,10 @@
{createManagedProcess, writeTextFile, supervisor, runtimeDir, logDir, stateDir}:
{instanceSuffix ? "", instanceName ? "supervisord${instanceSuffix}", inetHTTPServerPort ? 9001, postInstall ? ""}:
{ instanceSuffix ? ""
, instanceName ? "supervisord${instanceSuffix}"
, inetHTTPServerPort ? 9001
, postInstall ? ""
}:
let
includeDir = "${stateDir}/lib/${instanceName}/conf.d";

View File

@ -1,5 +1,12 @@
{createManagedProcess, stdenv, subversion, runtimeDir, forceDisableUserChange}:
{instanceSuffix ? "", instanceName ? "svnserve${instanceSuffix}", port ? 3690, svnBaseDir, svnGroup, postInstall ? ""}:
{ instanceSuffix ? ""
, instanceName ? "svnserve${instanceSuffix}"
, port ? 3690
, svnBaseDir
, svnGroup
, postInstall ? ""
}:
let
pidFile = "${runtimeDir}/${instanceName}.pid";