rework notify system (wip)
This commit is contained in:
		
							parent
							
								
									2d558bf6f0
								
							
						
					
					
						commit
						2228c8035d
					
				
					 12 changed files with 22 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -88,7 +88,7 @@ start_hook_daemon(){
 | 
			
		|||
    echocolor "[$APPNAME]" "listening to inotify events in $dir"
 | 
			
		||||
    # scan for '/mnt/experiences/creatorname/#234/ MODIFY foo.glb' e.g.
 | 
			
		||||
    # scan for '/mnt/experiences/creatorname/#234/ MOVED_TO foo.glb' e.g.
 | 
			
		||||
    inotifywait -r -m $dir | awk '$2 ~ /(CREATE|MODIFY|MOVED_TO|DELETE)/ { system("'$0' hook inotify_"$2" "$1""$3) }' &
 | 
			
		||||
    inotifywait -r -m $dir | awk '/.*/ { print $0 }; $2 ~ /(CREATE|MODIFY|MOVED_TO|DELETE)/ && $3 ~ /datapackage/ { system("'$0' hook datapackage_"$2" "$1""$3) }' &
 | 
			
		||||
  done
 | 
			
		||||
 | 
			
		||||
  # force-trigger processing hooks in /mnt
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1
									
								
								manyfold/root/hook.d/datapackage_MOVED_TO
									
										
									
									
									
										Symbolic link
									
								
							
							
						
						
									
										1
									
								
								manyfold/root/hook.d/datapackage_MOVED_TO
									
										
									
									
									
										Symbolic link
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
datapackage_MODIFY
 | 
			
		||||
| 
						 | 
				
			
			@ -1 +0,0 @@
 | 
			
		|||
inotify_MODIFY
 | 
			
		||||
							
								
								
									
										20
									
								
								manyfold/usr/src/app/config/initializers/xrforge.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								manyfold/usr/src/app/config/initializers/xrforge.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,20 @@
 | 
			
		|||
Rails.application.config.to_prepare do
 | 
			
		||||
  Model # Zeitwerk autoload model
 | 
			
		||||
 | 
			
		||||
  # Reopen the Model class to add new functionality
 | 
			
		||||
  # This must match the name of your ActiveRecord class exactly.
 | 
			
		||||
  class Model
 | 
			
		||||
    # The 'after_save' macro is now run within the context of the existing Model class.
 | 
			
		||||
    after_save :execute_initializer_after_save
 | 
			
		||||
 | 
			
		||||
    # Define the new method to be executed on save.
 | 
			
		||||
    def execute_initializer_after_save
 | 
			
		||||
      # Your custom logic to execute after Model.save or Model.update! goes here.
 | 
			
		||||
      
 | 
			
		||||
      # 📝 Example Logic:
 | 
			
		||||
      puts "\n-------- JA --------- #{self.id}\n\n"
 | 
			
		||||
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
		Loading…
	
	Add table
		
		Reference in a new issue