(grammar help needed) How do I understand "upon which" in this context?
Rip’s story was soon told, for the whole twenty long years had been to him but as one night. The neighbors stared when they heard it; some were seen to wink at each other, and put their tongues in their cheeks: and the self-important man in the cocked hat, who, when the alarm was over, had returned to the field, screwed down the corners of his mouth, and shook his head—***upon which there was a general shaking of the head throughout the assemblage.***
What does "which" refer to here? and what is linked to "upon"? and what's the meaning of "upon which"? how do I interpret the whole sentence?
it's always hard to understand "upon". Thanks in advance.