コード例 #1
0
        public void WithInMemoryServer_InvalidPort_ServerStartFails()
        {
            var nextFreeTcpPort = TcpPortHelper.NextFreeTcpPort();

            // intentionally block port
            var listener = new TcpListener(IPAddress.Any, nextFreeTcpPort);

            listener.Start();

            var backendAddress = "http://*****:*****@"c:\windows\System32\cmd.exe";
            });

            var server = builder.Create();

            try
            {
                server.Start();
            }
            catch
            {
                // ignored
            }

            Assert.IsNotNull(listener);
            Assert.AreEqual(JobbrState.Error, server.State, "The server should be in error state if a component didn't start");
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var jobbrBuilder = new JobbrBuilder();

            jobbrBuilder.AddForkedExecution(config =>
            {
                config.JobRunDirectory             = "C:/temp";
                config.JobRunnerExecutable         = "Sandbox.JobRunner.exe";
                config.MaxConcurrentProcesses      = 4;
                config.IsRuntimeWaitingForDebugger = false;
            });

            jobbrBuilder.AddJobs(repo =>
            {
                repo.Define("ProgressJob", "Sandbox.JobRunner.Jobs.ProgressJob")
                .WithTrigger("* * * * *")
                .WithTrigger(DateTime.UtcNow.AddSeconds(30), new RunParameter {
                    Param1 = "foo", Param2 = 1337
                });

                repo.Define("ParameterizedJob", "Sandbox.JobRunner.Jobs.ParameterizedJob")
                .WithParameter(new RunParameter {
                    Param1 = "default job param", Param2 = 1000
                })
                .WithTrigger("* * * * *")
                .WithTrigger(DateTime.UtcNow.AddSeconds(30), new RunParameter {
                    Param1 = "customized", Param2 = 5000
                });

                repo.Define("ArtefactJob", "Sandbox.JobRunner.Jobs.JobWithArtefacts")
                .WithTrigger("* * * * *");
            });

            jobbrBuilder.AddWebApi(config =>
            {
                config.BackendAddress = "http://localhost:1337";
            });

            jobbrBuilder.AddMsSqlStorage(c =>
            {
                c.ConnectionString        = "Data Source=localhost\\sqlexpress;Initial Catalog=JobbrWebApiSandbox;Integrated Security=True";
                c.DialectProvider         = new SqlServer2017OrmLiteDialectProvider();
                c.CreateTablesIfNotExists = true;
            });

            using (var server = jobbrBuilder.Create())
            {
                server.Start(20000);

                Console.ReadLine();

                server.Stop();
            }
        }
コード例 #3
0
        public void WithInMemoryServer_ServerHasStarted_StatusEndpointIsAvailable()
        {
            var backendAddress = "http://*****:*****@"c:\windows\System32\cmd.exe";
            });

            var server = builder.Create();

            server.Start();

            var statusResponse = new HttpClient().GetAsync(backendAddress + "/fex/status").Result;

            Assert.AreEqual(HttpStatusCode.OK, statusResponse.StatusCode);
        }
コード例 #4
0
        public static void Main(string[] args)
        {
            var jobbrBuilder = new JobbrBuilder();

            // Dispatch the execution to a separate process. See the Project "Demo.JobRunner" for details
            jobbrBuilder.AddForkedExecution(config =>
            {
                config.JobRunDirectory             = "C:/temp";
                config.JobRunnerExecutable         = "../../../Demo.JobRunner/bin/Debug/Demo.JobRunner.exe";
                config.MaxConcurrentProcesses      = 1;
                config.IsRuntimeWaitingForDebugger = true;
            }
                                            );

            // Setup an initial set of jobs with a unique name and the corresponding CLR Type.
            // Note: The Server does not reference the assembly containing the type since the Runner (see above) will activate and execute the job
            jobbrBuilder.AddJobs(repo =>
            {
                repo.Define("ProgressJob", "Demo.MyJobs.ProgressJob")
                .WithTrigger("* * * * *");
            });

            // Expose a Rest-API that is compatible with any browser and the Jobbr.Client
            jobbrBuilder.AddWebApi(config =>
            {
                config.BackendAddress = "http://*****:*****@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\temp\jobbr.mdf;Integrated Security=True;Connect Timeout=30";
            //    c.Schema = "Jobbr";
            //});

            // Uncomment to use RavenDB as storage
            // (start a ravendb server by executing packages\RavenDB.Server.3.5.3\tools\RavenDB.Server.exe)
            //jobbrBuilder.AddRavenDbStorage(config =>
            //{
            //    config.Url = "http://localhost:8080";
            //    config.Database = "Jobbr";
            //});

            // Register your very own component that gets as JobbrComponent and can request specific implementations with constructor injection
            jobbrBuilder.Register <IJobbrComponent>(typeof(MyExtension));

            using (var server = jobbrBuilder.Create())
            {
                server.Start();

                // Trigger a new Job from here. How-ever this does not make sense usually...
                // Better approach would be to use the Client Libraries to access the WebAPI
                // MyExtension.Instance.JobManagementService.AddTrigger(new InstantTrigger() { JobId = 1, IsActive = true });

                Console.ReadLine();

                server.Stop();
            }
        }
コード例 #5
0
        public static void Main(string[] args)
        {
            const string baseAddress     = "http://localhost:1338/";
            const string jobRunDirectory = "C:/temp";

            if (Directory.Exists(jobRunDirectory) == false)
            {
                Directory.CreateDirectory(jobRunDirectory);
            }

            var jobbrBuilder = new JobbrBuilder();

            jobbrBuilder.AddForkedExecution(config =>
            {
                config.JobRunDirectory        = jobRunDirectory;
                config.JobRunnerExecutable    = "../../../Sample.JobRunner/bin/Debug/Sample.JobRunner.exe";
                config.MaxConcurrentProcesses = 2;
            });

            jobbrBuilder.AddJobs(repo =>
            {
                repo.Define(typeof(MinutelyJob).Name, typeof(MinutelyJob).FullName)
                .WithTrigger("* * * * *", parameters: new { SomeProperty = "foobar" }, validFromDateTimeUtc: new DateTime(2000, 1, 1), validToDateTimeUtc: new DateTime(2100, 1, 1), userId: "ozu", userDisplayName: "olibanjoli")
                .WithParameter(new
                {
                    Foo    = "Bar",
                    Nested = new
                    {
                        Priority = "High",
                        Comment  = "Heyho!"
                    }
                })
                .WithTrigger(DateTime.Now.Add(TimeSpan.FromDays(1337)), new { Foo = "bar" }, "ozu", "olibanjoli");

                repo.Define(typeof(MinutelyJob).Name + "-2", typeof(MinutelyJob).FullName)
                .WithTrigger("* * * * *", parameters: new { SomeProperty = "foobar" }, validFromDateTimeUtc: new DateTime(2000, 1, 1), validToDateTimeUtc: new DateTime(2100, 1, 1), userId: "ozu", userDisplayName: "olibanjoli")
                .WithParameter(new
                {
                    Foo    = "Bar",
                    Nested = new
                    {
                        Priority = "High",
                        Comment  = "Heyho!"
                    }
                });

                repo.Define(typeof(HourlyJob).Name, typeof(HourlyJob).FullName)
                .WithTrigger("0 * * * *", parameters: new { Name = "Jack Bauer", Unit = "CTU", Skills = "Headshot" })
                .WithParameter(new
                {
                    Foo    = "Bar",
                    Nested = new
                    {
                        Equipment = "Nuke",
                    }
                });


                repo.Define(typeof(DailyJob).Name, typeof(DailyJob).FullName)
                .WithTrigger("0 0 * * *", parameters: new { Name = "Jack Bauer", Unit = "CTU", Skills = "Headshot" })
                .WithParameter(new
                {
                    Foo    = "Bar",
                    Nested = new
                    {
                        Equipment = "Nuke",
                    }
                });

                repo.Define(typeof(FailingJob).Name, typeof(FailingJob).FullName)
                .WithTrigger("*/2 * * * *", parameters: new { SomeProperty = "foobar" })
                .WithParameter(new
                {
                    Bla = "Blub",
                    Foo = "Bar"
                });
            });

            jobbrBuilder.AddWebApi(config => config.BackendAddress = $"{baseAddress}api");
            jobbrBuilder.AddDashboard(config =>
            {
                config.BackendAddress          = $"{baseAddress}";
                config.SoftDeleteJobRunOnRetry = true;
            });
            //jobbrBuilder.AddRavenDbStorage(config =>
            //{
            //    config.Url = "http://localhost:8080/";
            //    config.Database = "Jobbr";
            //});
            jobbrBuilder.AddMsSqlStorage(config =>
            {
                config.ConnectionString        = "Data Source=localhost\\SQLExpress;Initial Catalog=JobbrDashboard2;Connect Timeout=5;Integrated Security=True";
                config.CreateTablesIfNotExists = true;
            });

            using (var jobbr = jobbrBuilder.Create())
            {
                jobbr.Start(20000);
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("Jobbr is running. Press Enter to quit");
                Console.ResetColor();
                Console.ReadLine();
            }
        }