this used to happen a lot during my pms years. I would wake up in the middle of the night, totally unable to sleep, and relive all the most embarrassing or painful incidents of my past life. My solution was to get up and write it all down. These became the kernels of some of my best stories. Once it was written down, I could let go of it, but it took me a long time to find a strategy.
The other thing that helped was figuring out why I woke up in the first place. It often happend while DH was travelling on business or family matters. If I was alone in the house it was almost impossible to sleep. After a lot of help, counselling, treatment for depression, spiritual growth I learned to trust God and let go of a lot of anxiety that was sapping my energy.
I also recently learned that waking up hungry in the middle of the night is an actual disorder, one that should be taken care of by my current medical diet and treatment.