Optimal control of production rate in a failure prone manufacturing system

Consider a manufacturing system producing a single commodity. The manufacturing system can be in one of two states: functional and failed. It moves back and forth between these two states as a continuous time Markov chain, with mean time between failures = 1/q1, and mean time to repair 1/q2. When functional, the manufacturing system can produce at up to a maximum rate d. When failed, it cannot produce the commodity at all.