<commit_before>require "rb-inotify"

notifier = INotify::Notifier.new
# Beware not adding too many mirectories,
# i have enabled recursive watching and that's heavy
# please chek on a virtual machine or somewhere safe

# paths    = [
#     "/home/alessio/joomlainstallation1/images",
#     "/home/alessio/joomlainstallation2/images",
#     "/home/alessio/joomlainstallation3/images",
#     "/home/alessio/joomlainstallation4/images",
# ]

paths    = [
    "/home/alessio/watchdog",
]
pwd = File.dirname(__FILE__)
unwanted = [".gif", ".php"]         # List of unwanted extensions
moveto   = "/home/alessio/trash"    # set to nil if you want to delete files instead of moving them for manual inspection
#moveto   = pwd+"/trash"            # or uncomment me to save the unwanted files here
var_run  = "/var/run"               # Change me to a directory you can write, change the same parameter in kill.sh
#var_run  = pwd                     # or uncomment me to save the pid here (remember to update the kill file)
waitfor  = 60                       # wait for other istance to exit, set to nil to exit immediately


# i prefer having only one instance
if File.exists?("#{var_run}/rdog.pid")
    puts "\nI am allready runnig!"
    exit if waitfor.nil?

    puts "Wainting availability"
    ws = Time.now.to_i
    while File.exists?("#{var_run}/rdog.pid")
        wn = Time.now.to_i
        if (wn - ws) >= waitfor
            puts "Too busy, max time reached!"
            exit
        end
    end
end

# Saving PID to file so you can set crontab to call kill.sh to shutdown and relaunch
puts "\nI am #{Process.pid}"
File.open("#{var_run}/rdog.pid", 'w') {|f| f.write(Process.pid)}
<commit_msg>removed debug code<commit_after>require "rb-inotify"

notifier = INotify::Notifier.new
# Beware not adding too many mirectories,
# i have enabled recursive watching and that's heavy
# please chek on a virtual machine or somewhere safe

paths    = [
    "/home/alessio/joomlainstallation1/images",
    "/home/alessio/joomlainstallation2/images",
    "/home/alessio/joomlainstallation3/images",
    "/home/alessio/joomlainstallation4/images",
]

pwd = File.dirname(__FILE__)
unwanted = [".gif", ".php"]         # List of unwanted extensions
moveto   = "/home/alessio/trash"    # set to nil if you want to delete files instead of moving them for manual inspection
#moveto   = pwd+"/trash"            # or uncomment me to save the unwanted files here
var_run  = "/var/run"               # Change me to a directory you can write, change the same parameter in kill.sh
#var_run  = pwd                     # or uncomment me to save the pid here (remember to update the kill file)
waitfor  = 60                       # wait for other istance to exit, set to nil to exit immediately


# i prefer having only one instance
if File.exists?("#{var_run}/rdog.pid")
    puts "\nI am allready runnig!"
    exit if waitfor.nil?

    puts "Wainting availability"
    ws = Time.now.to_i
    while File.exists?("#{var_run}/rdog.pid")
        wn = Time.now.to_i
        if (wn - ws) >= waitfor
            puts "Too busy, max time reached!"
            exit
        end
    end
end

# Saving PID to file so you can set crontab to call kill.sh to shutdown and relaunch
puts "\nI am #{Process.pid}"
File.open("#{var_run}/rdog.pid", 'w') {|f| f.write(Process.pid)}

{'fraction_non_alphanumeric': 0.10474189675870348, 'fraction_numerical': 0.003601440576230492, 'mean_word_length': 2.7115812917594653, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3323965', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1064, 'n_words': 362}