m 3 rtorrent: cleanup logging

This commit is contained in:
makefu 2016-08-24 11:34:48 +02:00
parent 56e8681fd2
commit aa21de8764
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225

View File

@ -11,11 +11,14 @@ let
fpm-socket = "/var/run/php5-fpm-rutorrent.sock"; fpm-socket = "/var/run/php5-fpm-rutorrent.sock";
webdir = rucfg.webdir; webdir = rucfg.webdir;
systemd-logfile = cfg.workDir + "/rtorrent-systemd.log";
# must be in path of php-fpm and rtorrent when started ...
rutorrent-deps = with pkgs; [ curl php coreutils procps ffmpeg mediainfo ] ++ rutorrent-deps = with pkgs; [ curl php coreutils procps ffmpeg mediainfo ] ++
(if (config.nixpkgs.config.allowUnfree or false) then (if (config.nixpkgs.config.allowUnfree or false) then
trace "enabling unfree packages for rutorrent" [ unrar unzip ] else trace "enabling unfree packages for rutorrent" [ unrar unzip ] else
trace "not enabling unfree packages for rutorrent because allowUnfree is unset" []) trace "not enabling unfree packages for rutorrent because allowUnfree is unset" []);
;
rutorrent = pkgs.stdenv.mkDerivation { rutorrent = pkgs.stdenv.mkDerivation {
name = "rutorrent-src-3.7"; name = "rutorrent-src-3.7";
src = pkgs.fetchFromGitHub { src = pkgs.fetchFromGitHub {
@ -24,6 +27,7 @@ let
rev = "b727523a153454d4976f04b0c47336ae57cc50d5"; rev = "b727523a153454d4976f04b0c47336ae57cc50d5";
sha256 = "0s5wa0jnck781amln9c2p4pc0i5mq3j5693ra151lnwhz63aii4a"; sha256 = "0s5wa0jnck781amln9c2p4pc0i5mq3j5693ra151lnwhz63aii4a";
}; };
phases = [ "patchPhase" "installPhase" ]; phases = [ "patchPhase" "installPhase" ];
patchPhase = '' patchPhase = ''
cp -r $src src/ cp -r $src src/
@ -37,7 +41,7 @@ let
echo "replacing scgi port and host variable in conf/config.php" echo "replacing scgi port and host variable in conf/config.php"
''; '';
}; };
systemd-logfile = cfg.workDir + "/rtorrent-systemd.log";
configFile = pkgs.writeText "rtorrent-config" '' configFile = pkgs.writeText "rtorrent-config" ''
# THIS FILE IS AUTOGENERATED # THIS FILE IS AUTOGENERATED
${optionalString (cfg.listenPort != null) '' ${optionalString (cfg.listenPort != null) ''
@ -46,7 +50,7 @@ let
''} ''}
${optionalString (cfg.watchDir != null) '' ${optionalString (cfg.watchDir != null) ''
schedule = watch_directory,5,5load_start=${cfg.watchDir}/*.torrent schedule = watch_directory,5,5,load_start=${cfg.watchDir}/*.torrent
''} ''}
directory = ${cfg.downloadDir} directory = ${cfg.downloadDir}
@ -68,8 +72,6 @@ let
log.add_output = "notice", "rtorrent-systemd" log.add_output = "notice", "rtorrent-systemd"
log.add_output = "info", "rtorrent-systemd" log.add_output = "info", "rtorrent-systemd"
# log.add_output = "debug", "rtorrent-systemd" # log.add_output = "debug", "rtorrent-systemd"
log.execute = ${systemd-logfile}.execute
log.xmlrpc = ${systemd-logfile}.xmlrpc
${cfg.extraConfig} ${cfg.extraConfig}
''; '';
@ -163,14 +165,6 @@ let
default = true; default = true;
}; };
logLevel = mkOption {
type = types.str;
description = ''
Log level to be used for systemd log
'';
default = "warn";
};
downloadDir = mkOption { downloadDir = mkOption {
type = types.path; type = types.path;
description = '' description = ''
@ -210,6 +204,10 @@ let
see ${cfg.package}/share/doc/rtorrent/rtorrent.rc see ${cfg.package}/share/doc/rtorrent/rtorrent.rc
''; '';
example = literalExample ''
log.execute = ${config.makefu.rtorrent.workDir}/execute.log
log.xmlrpc = ${config.makefu.rtorrent.workDir}/xmlrpc.log
'';
default = ""; default = "";
}; };
@ -248,9 +246,10 @@ let
''; '';
ExecStart = "${pkgs.tmux.bin}/bin/tmux new-session -s rt -n rtorrent -d 'PATH=/bin:/usr/bin:${makeBinPath rutorrent-deps} ${cfg.package}/bin/rtorrent'"; ExecStart = "${pkgs.tmux.bin}/bin/tmux new-session -s rt -n rtorrent -d 'PATH=/bin:/usr/bin:${makeBinPath rutorrent-deps} ${cfg.package}/bin/rtorrent'";
# PrivateTmp = true; ## you can simply sudo -u rtorrent tmux a if privateTmp is set to false
## now you can simply sudo -u rtorrent tmux a
## otherwise the tmux session is stored in some private folder in /tmp ## otherwise the tmux session is stored in some private folder in /tmp
PrivateTmp = false;
WorkingDirectory = cfg.workDir; WorkingDirectory = cfg.workDir;
Restart = "on-failure"; Restart = "on-failure";
User = "${cfg.user}"; User = "${cfg.user}";
@ -268,7 +267,6 @@ let
} // (optionalAttrs webcfg.enable { } // (optionalAttrs webcfg.enable {
rutorrent-prepare = { rutorrent-prepare = {
after = [ "rtorrent-daemon.service" ]; after = [ "rtorrent-daemon.service" ];
bindsTo = [ "rtorrent-daemon.service" ];
wantedBy = [ "rtorrent-daemon.service" ]; wantedBy = [ "rtorrent-daemon.service" ];
serviceConfig = { serviceConfig = {
Type = "oneshot"; Type = "oneshot";
@ -277,7 +275,8 @@ let
ExecStart = pkgs.writeDash "create-webconfig-dir" '' ExecStart = pkgs.writeDash "create-webconfig-dir" ''
if [ ! -e ${webdir} ];then if [ ! -e ${webdir} ];then
echo "creating webconfiguration directory for rutorrent: ${webdir}" echo "creating webconfiguration directory for rutorrent: ${webdir}"
cp -r ${rucfg.package} ${webdir} cp -vr ${rucfg.package} ${webdir}
echo "setting permissions for webdir to ${cfg.user}:${nginx-group}"
chown -R ${cfg.user}:${nginx-group} ${webdir} chown -R ${cfg.user}:${nginx-group} ${webdir}
chmod -R 770 ${webdir} chmod -R 770 ${webdir}
else else
@ -293,7 +292,7 @@ let
users.rtorrent = { users.rtorrent = {
uid = genid "rtorrent"; uid = genid "rtorrent";
home = cfg.workDir; home = cfg.workDir;
group = nginx-group; group = nginx-group; # required for rutorrent to work
shell = "/bin/sh"; #required for tmux shell = "/bin/sh"; #required for tmux
isSystemUser = true; isSystemUser = true;
createHome = true; createHome = true;
@ -362,6 +361,4 @@ let
}; };
}; };
}; };
in in out
out