Many years ago I had a beloved dog that was my "best friend" for 14 years. She was about 11 when my son was born, and the next three years were very hard on her. At the end, she started to do some of the same things you mention here. She was 14 and had bad arthritis problems. Eventually she couldn't even get up and walk. I had to buy those disposable pads you put on beds in nursing homes and lay her on those, on top of a vinyl tablecloth. She was embarrassed when she pooped and peed, but I would clean it up, she never ate it. Your dog is probably embarrassed he is messing in the house and that's why he's eating his feces, which is NOT GOOD.
I took my dog to the vet and she had a disk problem that was not going to get better, and they wouldn't operate because of her advanced age. They advised me to put her down, but I just couldn't do it. I made that poor dog suffer at least another month or two just because she was my best friend and I couldn't bear to let her go. Looking back on it, the kindest thing I could have done would have been to have put her down immediately. Now, instead of all the good memories I have of her, I only have memories of those last painful days when she clearly had no quality of life left.
So that's my story. If your dog is sick, and can recover, then follow that course of action. But if he has such physical problems due to old age that he cannot recover or have quality of life, then do both your dog and yourself a favor, and put him down.
My heart goes out to you. There's hardly a day that goes by that I don't regret my decision to try to prolong my dog's life, long after it was her time to go. Pets have the luxury of euthanization; something we humans do not. And sometimes it is the merciful and loving thing to do.
Good luck. I'll say a prayer for you.