i was in exactly the same position in a software engineering role a couple of years back.
in fact, truth be told, i'd gotten stuck in a rut for at least two years but not really noticed. was unhappy, tired, annoyed, feeling undervalued by my employer etc. luckily i did wake up to the fact that it was going in a bad direction and would likely have taken me down with it.
i knew i had to get out. still, it took me a while to build up the courage. it's amazing now to think how i tricked myself for so long that i could not leave for this or that reason. truth is, no job, no possible tight financial circumstances, nothing is worth putting yourself at serious risk of mental and/or health problems which can be brought on by such high stress / unhappiness as i was feeling.
people who don't look after themselves can fall foul of some serious problems from heart conditions to depression.
for me the first step was spotting the problem, realising that i just was not happy.
the second step was working out what the root cause was, for me my employer / work conditions.
the third step was a little psychological trickery to get me to more rationally apraise the situation. i knocked up an excel spreadsheet with multiple tabs, one each for :
stay with current employer,
quit now and leave without a job,
getting work outside the industry, ie manual work
getting another software job
going back to uni.
on ech tab i had 3 columns, pros, cons and actions.
i just filled lists out under each heading on each tab.
writing it all down gave me a much clearer picture of my options.
prior to writing it down, every time i tried to think my way out of my current situation, i'd get stuck in some mental loop, that got me nowhere except upset. but writing it down was a calming experience and helped to be realistic.
that's probably when i first strarted to believe there was a way out and things weren't as bad as they often felt.
i actually ended up taking some time out, went back to uni and did an MSc in something i just had an interest in. it was the best thing i've done in the last decade. i now am back in control of my life. i now know what i had previously forgotten which is that i can do what i damn well like with my life.
i'll round off with a little tip that someone once told my wife and she passed on to me. it sounds silly now but again, it's one of those little things that i found helped me at times when i started to feel like i couldn't see the wood for the trees.
she got me to print out the words "What would I advise somebody else to do?" in largish font, cut it out and tape it across the top of my monitor at home. when you're not sure what to do, think if it was you giving advice to somebody you know who asked you for help with the same issue you now face, what would you suggest to them.
like i say, it sounds cheesy now but i found it to be just another of those tricks that can tease out some of your best ideas when they seem to have deserted you.
and as i type that, i notice those words are still taped to my monitor, had gotton so used to them being there i hadn't noticed them.
best of luck, and whatever happens, for gods sake don't give up on yourself, there is better times ahead for you, you just might not be able to see the path right now.