import { EventEmitter } from 'events';

import { Logger } from './util';
import { Service, ServiceConstructor, ServiceContainer } from './service';

export class Kaptan extends EventEmitter {
  public readonly logger: Logger;
  public readonly services: ServiceContainer;

  constructor(label: string = 'kaptan') {
    super();

    this.logger = new Logger(label);
    this.services = new ServiceContainer(this);
  }

  public use(service: ServiceConstructor, options: {[key:string]: any} = {}) {
    service = Service.copy(Service.getServiceName(service), service);
    
    if (!service.Options) {
      service.Options = {};
    }

    service.Options = { ...service.Options, ...options };
    this.services.add(service);
  }

  public start() {
    this.services.spawn();
  }
}

import { EventEmitter } from 'events';

import { Logger } from './util';
import { ServiceConstructor, ServiceContainer } from './service';

export class Kaptan extends EventEmitter {
  public readonly logger: Logger;
  public readonly services: ServiceContainer;

  constructor(label: string = 'kaptan') {
    super();

    this.logger = new Logger(label);
    this.services = new ServiceContainer(this);
  }

  public use(service: ServiceConstructor, options: {[key:string]: any} = {}) {
    if (!service.Options) {
      service.Options = {};
    }

    service.Options = { ...service.Options, ...options };
    this.services.add(service);
  }

  public start() {
    this.services.spawn();
  }
}

--- 
+++ 
@@ -1,7 +1,7 @@
 import { EventEmitter } from 'events';
 
 import { Logger } from './util';
-import { ServiceConstructor, ServiceContainer } from './service';
+import { Service, ServiceConstructor, ServiceContainer } from './service';
 
 export class Kaptan extends EventEmitter {
   public readonly logger: Logger;
@@ -15,6 +15,8 @@
   }
 
   public use(service: ServiceConstructor, options: {[key:string]: any} = {}) {
+    service = Service.copy(Service.getServiceName(service), service);
+    
     if (!service.Options) {
       service.Options = {};
     }
Add duplicate service to the services instead of the original one

