Esempio n. 1
0
        /// <summary>
        /// The main instance of WaveBox which runs the server.  Creates necessary directories, initializes
        /// database and settings, and starts all associated services.
        /// </summary>
        public void Start()
        {
            logger.IfInfo("Initializing WaveBox " + WaveBoxService.BuildVersion + " on " + WaveBoxService.OS.ToDescription() + " platform...");

            // Initialize ImageMagick
            try {
                ImageMagickInterop.WandGenesis();
            } catch (Exception e) {
                logger.Error("Error loading ImageMagick DLL:", e);
            }

            // Create directory for WaveBox's root path, if it doesn't exist
            string rootDir = ServerUtility.RootPath();

            if (!Directory.Exists(rootDir))
            {
                Directory.CreateDirectory(rootDir);
            }

            // Create directory for WaveBox Web UI themes, if it doesn't exist
            string themeDir = ServerUtility.ExecutablePath() + "themes/";

            if (!Directory.Exists(themeDir))
            {
                Directory.CreateDirectory(themeDir);
            }

            // Perform initial setup of Settings, Database
            Injection.Kernel.Get <IDatabase>().DatabaseSetup();
            Injection.Kernel.Get <IServerSettings>().SettingsSetup();

            // Start services
            try {
                // Initialize factory, so it can register all services for deployment
                ServiceFactory.Initialize();

                // Start user defined services
                if (Injection.Kernel.Get <IServerSettings>().Services != null)
                {
                    ServiceManager.AddList(Injection.Kernel.Get <IServerSettings>().Services);
                }
                else
                {
                    logger.Warn("No services specified in configuration file!");
                }

                ServiceManager.StartAll();
            } catch (Exception e) {
                logger.Warn("Could not start one or more WaveBox services, please check services in your configuration");
                logger.Warn(e);
            }

            // Temporary: create test and admin user
            Injection.Kernel.Get <IUserRepository>().CreateUser("test", "test", Role.User, null);
            Injection.Kernel.Get <IUserRepository>().CreateUser("admin", "admin", Role.Admin, null);

            return;
        }
Esempio n. 2
0
        /// <summary>
        /// Stop the WaveBox main
        /// </summary>
        public void Stop()
        {
            // Stop all running services
            ServiceManager.StopAll();
            ServiceManager.Clear();

            // Dispose of ImageMagick
            try {
                ImageMagickInterop.WandTerminus();
            } catch (Exception e) {
                logger.Error("Error loading ImageMagick DLL:", e);
            }
        }