Classis case of not getting enough 12VDC power from the coach battereis to the genset to start.
The reason it starts when engine is running is the coach batteries are tied together with the chassis battery as well as the engine alternator when engine is running!
So the coach battery may be dead or the connections corroded and when the engine comes online, that power is available to start the generator.
If you will post up the model of your RV, we can look at wiring to show where they tie together. That info should be on the label near the driver's seat if model is not known or handy.
__________________
Richard
Why no RV year, make and floorplan on MY signature as we suggest for others?
I currently DO NOT have one!