title: How to supervise cluster singleton in Akka?
body: <p>I'm trying to supervise an Akka Actor, more specifically a <a href="http://doc.akka.io/docs/akka/current/scala/cluster-singleton.html" rel="noreferrer">Cluster Singleton</a> created using <code>ClusterSingletonManager</code>. I'm trying to achieve more control over exceptions, logs and Actor's life cycle.</p>
  
  <p>Unfortunately, after implementing a solution, I made a Singleton Actor throw exceptions, but nothing was show in the logs, nor the Actor or Cluster was shutdown.</p>
  
  <p>My implementation is as follows:</p>
  
  <pre><code>object SingletonSupervisor {
    case class CreateSingleton(p: Props, name: String)
  }
  
  class SingletonSupervisor extends Actor with ActorLogging {
    override val supervisorStrategy =
      OneForOneStrategy(maxNrOfRetries = 0, withinTimeRange = 1.minute) {
        case x: ActorInitializationException =&gt;
          log.error(s"Actor=&lt;${x.getActor}&gt; trowed an exception=&lt;${x.getCause}&gt; with message=&lt;${x.getMessage}&gt;")
          Stop
  
        case x: ActorKilledException =&gt; Stop
  
        case x: DeathPactException =&gt; Stop
  
        case x: Exception =&gt;
          log.error(s"Some actor threw an exception=&lt;${x.getCause}&gt; with message=&lt;${x.getMessage}&gt;, trace=&lt;${x.getStackTrace}&gt;")
          Escalate
      }
  
    def receive = {
      case CreateSingleton(p: Props, name: String) =&gt;
        sender() ! context.actorOf(p)
        context.actorOf(ClusterSingletonManager.props(
          singletonProps = p,
          terminationMessage = PoisonPill,
          settings = ClusterSingletonManagerSettings(context.system)),
          name = name)
    }
  }
  </code></pre>
  
  <p>So, is it even possible to supervisor a Cluster Singlegon? If possible,  how should I attack this problem?</p>