public override bool Init()
        {
            log.Info("()");

            bool res = false;

            try
            {
                canIpnsLastSequenceNumber = Config.Configuration.CanIpnsLastSequenceNumber;
                api = new CanApi(Config.Configuration.CanEndPoint, ShutdownSignaling);

                // Construct profile server's contact information CAN object.
                canContactInformation = new CanProfileServerContact()
                {
                    PublicKey   = ProtocolHelper.ByteArrayToByteString(Config.Configuration.Keys.PublicKey),
                    IpAddress   = ProtocolHelper.ByteArrayToByteString(Config.Configuration.ExternalServerAddress.GetAddressBytes()),
                    PrimaryPort = (uint)Config.Configuration.ServerRoles.GetRolePort((uint)ServerRole.Primary)
                };


                initThread = new Thread(new ThreadStart(InitThread));
                initThread.Start();

                RegisterCronJobs();

                res         = true;
                Initialized = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }

            if (!res)
            {
                ShutdownSignaling.SignalShutdown();

                if ((initThread != null) && !initThreadFinished.WaitOne(25000))
                {
                    log.Error("Init thread did not terminated in 25 seconds.");
                }
            }

            log.Info("(-):{0}", res);
            return(res);
        }
Example #2
0
        public override bool Init()
        {
            log.Info("()");

            bool res = false;

            try
            {
                canApi = (CanApi)Base.ComponentDictionary["Network.ContentAddressNetwork.CanApi"];

                // Construct profile server's contact information CAN object.
                canContactInformation = new CanProfileServerContact()
                {
                    PublicKey   = ProtocolHelper.ByteArrayToByteString(Base.Configuration.Keys.PublicKey),
                    IpAddress   = ProtocolHelper.ByteArrayToByteString(Base.Configuration.ServerInterface.GetAddressBytes()),
                    PrimaryPort = (uint)Base.Configuration.ServerRoles.GetRolePort(ServerRole.Primary)
                };


                initThread = new Thread(new ThreadStart(InitThread));
                initThread.Start();

                res         = true;
                Initialized = true;
            }
            catch (Exception e)
            {
                log.Error("Exception occurred: {0}", e.ToString());
            }

            if (!res)
            {
                ShutdownSignaling.SignalShutdown();

                if ((initThread != null) && !initThreadFinished.WaitOne(25000))
                {
                    log.Error("Init thread did not terminated in 25 seconds.");
                }
            }

            log.Info("(-):{0}", res);
            return(res);
        }