Changeset 3872
- Timestamp:
- 08/20/10 14:12:55 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.4-stable/common/lib/Munin/Common/Config.pm
r3594 r3872 38 38 "onlynullcdef", "group_order", "pipe", "pipe_command", 39 39 "unknown_limit", "num_unknowns", "dropdownlimit", 40 "max_graph_jobs", "max_cgi_graph_jobs", "munin_cgi_graph_jobs" ); 40 "max_graph_jobs", "max_cgi_graph_jobs", "munin_cgi_graph_jobs", 41 "max_html_jobs", ); 41 42 42 43 my %bools = map { $_ => 1} qw(yes no true false on off 1 0); branches/1.4-stable/master/lib/Munin/Master/HTMLOld.pm
r3302 r3872 90 90 91 91 my $do_dump = 0; 92 my $do_fork = 0; # No effect in this program. 92 my $do_fork = 1; 93 my $max_running=6; 94 my $running=0; 95 93 96 94 97 sub html_startup { … … 123 126 $htmldir = $config->{htmldir}; 124 127 128 $max_running = &munin_get($config, "max_html_jobs", $max_running); 129 125 130 %comparisontemplates = instanciate_comparison_templates($tmpldir); 126 131 … … 163 168 my $groups = get_group_tree($config); 164 169 165 166 167 170 if (!defined($groups) or scalar(%{$groups} eq '0')) { 168 171 LOGCROAK "[FATAL] There is nothing to do here, since there are no nodes with any plugins. Please refer to http://munin-monitoring.org/wiki/FAQ_no_graphs"; 169 172 }; 170 173 171 172 174 if (defined $groups->{"name"} and $groups->{"name"} eq "root") { 173 175 $groups = $groups->{"groups"}; # root->groups … … 181 183 exit 0; 182 184 } 183 184 185 185 186 186 generate_group_templates($groups); … … 824 824 825 825 826 sub fork_and_work { 827 my ($work) = @_; 828 829 if (!$do_fork) { 830 831 # We're not forking. Do work and return. 832 DEBUG "[DEBUG] Doing work synchrnonously"; 833 &$work; 834 return; 835 } 836 837 # Make sure we don't fork too much 838 while ($running >= $max_running) { 839 DEBUG 840 "[DEBUG] Too many forks ($running/$max_running), wait for something to get done"; 841 look_for_child("block"); 842 --$running; 843 } 844 845 my $pid = fork(); 846 847 if (!defined $pid) { 848 ERROR "[ERROR] fork failed: $!"; 849 die "fork failed: $!"; 850 } 851 852 if ($pid == 0) { 853 854 # This block does the real work. Since we're forking exit 855 # afterwards. 856 857 &$work; 858 859 # See?! 860 861 exit 0; 862 863 } 864 else { 865 ++$running; 866 DEBUG "[DEBUG] Forked: $pid. Now running $running/$max_running"; 867 while ($running and look_for_child()) { 868 --$running; 869 } 870 } 871 } 872 873 826 874 sub generate_group_templates { 827 875 my $arr = shift || return; … … 837 885 if (defined $key->{'ngroups'} and $key->{'ngroups'}) { 838 886 # WTF: $key->{'groups'} = $key->{'groups'}; 839 generate_group_templates($key->{'groups'});887 fork_and_work(sub {generate_group_templates($key->{'groups'})}); 840 888 841 889 emit_group_template($key);
