I've had wicked bad chronic insomnia for about 25 years. You name it, I've tried it. Melatonin, nothing. Herbal teas, nothing. Lots of exercise, nope. Trazadone, as Trout suggested, no go.
Weed works great, but I build up tolerance fast, so after 3-4 days, nope. Xanax knocks me out, but again, tolerance kicks in after a few days, plus that shit rots your memory. Alcohol works, but I have to get toasty, and face it, it's bad for you long term.
So I rotate between the 3 things that do work. I'll take a couple Xanax on Sunday night to get a good rest before beginning my work week. I try to limit the Xanax to twice a week max. I like the buzz so I give 'em to my wife to dole out. I switch over to alcohol for a day or two. Then weed if I have any. Then if I'm having a bad week I may take Xanax for a 2nd time.
This is what works for me. I can't say it would work for you. It sure isn't what I call good for you. And I do tend to mix the three sometimes. All I know is that after a while, you will try anything.
I went nearly two full weeks with no sleep once. Was having auditory hallucinations. Hearing sirens, weird noises. I was afraid I was loosing my cookies. Then someone hooked me up with a couple Xanax. I took them at 10:00 pm on a Friday, and slept straight thru to 6:00 pm Saturday. Best sleep I ever had.
I don't recommend doing what I do. But I understand what you are going thru. The one thing I will recommend, is when you find what works, don't depend on only that. If smoking or edibles work, great, but give yourself a break every few days. You may have to live with a sleepless night or two, but it's worth if so you don't build up a tolerance.
Sorry for the long post. I'm just relating my personal experience so you know I understand where you are coming from.
Cherry Bomb x C99
"To be scientifically literate is to empower yourself to know when someone else is full of Bullshit."
-Neil deGrasse Tyson