mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
Add tasks for new proxy system
This commit is contained in:
parent
4fe339f51f
commit
89998e2f18
1 changed files with 29 additions and 20 deletions
11
Rakefile
11
Rakefile
|
@ -15,11 +15,12 @@ task :default => :test
|
|||
|
||||
desc "parse logs"
|
||||
task :parse_logs => [:environment] do
|
||||
Dir["/home/web/proxy/logs/*.log"].each do |log_path|
|
||||
hits = {}
|
||||
visits = {}
|
||||
visit_ips = {}
|
||||
|
||||
logfile = File.open '/var/log/nginx/neocities-sites.log.1', 'r'
|
||||
logfile = File.open log_path, 'r'
|
||||
|
||||
while hit = logfile.gets
|
||||
time, username, size, path, ip = hit.split ' '
|
||||
|
@ -45,6 +46,9 @@ task :parse_logs => [:environment] do
|
|||
visits.each do |username,visitcount|
|
||||
DB['update sites set views=views+? where username=?', visitcount, username].first
|
||||
end
|
||||
|
||||
FileUtils.rm log_path
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Update screenshots'
|
||||
|
@ -79,3 +83,8 @@ task :update_blocked_ips => [:environment] do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Compile domain map for nginx'
|
||||
task :compile_domain_map => [:environment] do
|
||||
File.open('./files/map.txt', 'w'){|f| Site.exclude(domain: nil).exclude(domain: '').select(:username,:domain).all.collect {|s| f.write "#{s.domain} #{s.username};\n" }}
|
||||
end
|
Loading…
Add table
Reference in a new issue