Ejemplo 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;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor for WaveBox service.  Initializes the service and sets up the graceful shutdown
        /// </summary>
        public WaveBoxService()
        {
            logger.IfInfo("Initializing WaveBoxService");
            try
            {
                // Name the service
                this.ServiceName = "WaveBox";

                // Register shutdown handlers for Unix or Windows
                this.RegisterShutdownHandler();

                // Detect operating system
                OS = ServerUtility.DetectOS();

                // Now that platform is detected, inject platform-specific classes
                InjectPlatformSpecificClasses();

                // Store version
                var assembly = Assembly.GetExecutingAssembly().GetName();
                BuildVersion = String.Format("{0}.{1}.{2}.{3}", assembly.Version.Major, assembly.Version.Minor, assembly.Version.Build, assembly.Version.Revision);

                // Build date detection
                BuildDate = ServerUtility.GetBuildDate();

                logger.IfInfo("BuildDate timestamp: " + BuildDate.ToUnixTime());

                // Get start up time
                StartTime = DateTime.UtcNow;

                // Create WaveBox's temporary folder
                if (!Directory.Exists(TempFolder))
                {
                    Directory.CreateDirectory(TempFolder);
                    logger.IfInfo("Created temp folder: " + TempFolder);
                }

                // Instantiate a WaveBox object
                wavebox = new WaveBoxMain();

                // Start it!
                this.OnStart();
            }
            // Handle any uncaught exceptions
            catch (Exception e)
            {
                ServerUtility.ReportCrash(e, false);
            }
        }
Ejemplo n.º 3
0
 public static string BackupPath(long queryId)
 {
     return(ServerUtility.RootPath() + BackupFileName(queryId));
 }