Lying there for too long not sleeping makes it more likely you’ll do the same in the future.
Do something relatively calming, but that will also get your mind off of wherever it was when you weren’t falling asleep. Reading, meditating, a brief walk, a light stack, even a not-intense tv show is fine (the blue-light filter on many tablets, or an app like f.lux is a good idea if you’re watching something). Just get out of your bed, and do something to facilitate thinking about anything else (or nothing at all).
lots of lists of “good” and “bad” foods out there for snacking: they’re a good starting point, but find out what works for you.
Milk is good for me. Too much water makes it more likely you’ll wake up in the middle of sleep, as well as making it harder to fall asleep, but being hydrated is important.
The break doesn’t have to be long, 15-30 minutes is a good lower bound, with an hour or a bit longer being the longest.
Just be comfortable, fairly calm, and give your head and body a chance to reset for another try.