Configuration
=============

Location
--------

The configuration file for ``goconserver`` is located at ``/etc/goconserver/server.conf``.
When the configuration is changed, reload using: ``systemctl restart goconserver.service``.
An example for the configuration could be found from
`Example Conf <https://github.com/xcat2/goconserver/blob/master/etc/goconserver/server.conf>`_.

Tag For xCAT
------------

xCAT generates a configuration file that includes a identifier on the first
line. For example:  ::

    #generated by xcat Version 2.13.10 (git commit 7fcd37ffb7cec37c021ab47d4baec151af547ac0, built Thu Jan 25 07:15:36 EST 2018)

``makegocons`` checks for this token and will not make changes to the
configuration file if it exists.  This gives the user the ability to customize
the configuration based on their specific site configuration.


Multiple Output Plugins
-----------------------

``goconserver`` support console redirection to multiple targets with ``file``,
``tcp`` and ``udp`` logger plugins. The entry could be found like below: ::

    console:
      # the console session port for client(congo) to connect.
      port: 12430

      logger:
        # for file logger
        file:
          # multiple file loggers could be specified
          # valid fields: name, logdir
          - name: default
            logdir: /var/log/goconserver/nodes/
          - name: xCAT
            logdir: /var/log/consoles

        tcp:
          - name: logstash
            host: briggs01
            port: 9653
            ssl_key_file: /etc/xcat/cert/server-cred.pem
            ssl_cert_file: /etc/xcat/cert/server-cred.pem
            ssl_ca_cert_file: /etc/xcat/cert/ca.pem

          - name: rsyslog
            host: sn02
            port: 9653

        udp:
          - name: filebeat
            host: 192.168.1.5
            port: 512

With the configuration above, the console log files for each node would be written in
both ``/var/log/goconserver/nodes/<node>.log`` and ``/var/log/consoles/<node>.log``.
In addition, console log content will be redirected into remote services
specified in the tcp and udp sections.

Verification
------------

To check if ``goconserver`` works correctly, see the log file ``/var/log/goconserver/server.log``.

    #. Check if TCP logger has been activated.

       When starting ``goconserver``, if the log message is like below, it
       means the TCP configuration has been activated. ::

         {"file":"github.com/xcat2/goconserver/console/logger/tcp.go (122)","level":"info","msg":"Starting TCP publisher: logstash","time":"2018-03-02T21:15:35-05:00"}
         {"file":"github.com/xcat2/goconserver/console/logger/tcp.go (122)","level":"info","msg":"Starting TCP publisher: sn02","time":"2018-03-02T21:15:35-05:00"}

    #. Debug when encounter error about TCP logger

       If the remote service is not started or the network is unreachable, the
       log message would be like below. ::

         {"file":"github.com/xcat2/goconserver/console/logger/tcp.go (127)","level":"error","msg":"TCP publisher logstash: dial tcp 10.6.27.1:9653: getsockopt: connection refused","time":"2018-03-07T21:12:58-05:00"}

       Check the service status and the network configuration including the
       ``selinux`` and ``iptable rules``. When the remote service works
       correctly, TCP or UDP logger of ``goconserver`` would recover automatically.

Reconnect Interval
------------------

If console node is defined with ``ondemand=false``, when the console connection
could not be established, ``goconserver`` would reconnect automatically. The
interval time could be specified at ::

    console:
      # retry interval in second if console could not be connected.
      reconnect_interval: 10

Performance Tuning
------------------

Adjust the worker numbers to leverage multi-core processor performance based on
the site configuration. ::

    global:
      # the max cpu cores for workload
      worker: 4

Debug
-----

The log level for ``goconserver`` is defined in ``/etc/goconserver/server.conf`` ::

    global:
      # debug, info, warn, error, fatal, panic
      log_level: info