Start() public method

public Start ( ) : void
return void
Exemplo n.º 1
0
        public static int Main(string[] args)
        {
            // parse arguments
            if (args.Length != 2) {
                System.Console.WriteLine("Usage: Cassini.exe [port] [path]");
                return 1;
            }
            int port = Int32.Parse(args[0]);
            string physicalPath = args[1];

            // start server
            Server server = new Server(port, "/", physicalPath, false);
            server.Start();

            // loop until forever
            while (true) {
                // TODO: maybe something to break out earlier?
                Thread.Sleep(60000);
            }

            // stop server
            server.Stop();

            return 0;
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            if (args.Length != 5)
            {
                Console.WriteLine("usage: m2net.AspNetHandler.exe senderId subAddr pudAddr physicalDir virtualDir");
                return;
            }

            string sender_id = args[0];
            string sub_addr = args[1];
            string pub_addr = args[2];
            string dir = args[3];
            string virt = args[4];

            if (!Directory.Exists(dir))
            {
                Console.WriteLine("Physical directory '{0}' does not exist.", dir);
                return;
            }

            Connection conn;
            try
            {
                conn = new Connection(sender_id, sub_addr, pub_addr);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not create Mongrel2 connection: " + ex.Message);
                return;
            }

            Server srv;
            try
            {
                srv = new Server(conn, virt, dir);
            }
            catch(Exception ex)
            {
                Console.WriteLine("Could not create ASP.NET server: " + ex.Message);
                return;
            }

            srv.Start();

            Console.WriteLine("Press enter to exit m2net.AspNetHandler.");
            Console.ReadLine();

            srv.Stop();
        }
Exemplo n.º 3
0
        public override bool Start()
        {
            base.Start();

            var di = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\www");

            if (!di.Exists)
            {
                di.CreateSubdirectory("www");
            }

            _server = new Server(Connection.Port, "/", di.FullName);

            _server.Start();
            return(true);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            ParseArgs(args);

              var mutex = new Mutex(false, "mycassini" + _portNumber);
              var mutex2 = new Mutex(false, "mycassinirunning" + _portNumber);

              if (_appPath == "stop")
              {
            mutex.WaitOne();
            mutex2.WaitOne();

            mutex2.ReleaseMutex();
            mutex.ReleaseMutex();
            return;
              }

              _server = new Cassini.Server(_portNumber, _virtRoot, _appPath);

              try
              {
            mutex2.WaitOne();
            _server.Start();
              }
              catch (Exception er)
              {
            Console.WriteLine(er);
              }

              while (mutex.WaitOne(0))
              {
            mutex.ReleaseMutex();
            Thread.Sleep(50);
              }

              mutex2.ReleaseMutex();
        }
Exemplo n.º 5
0
		/// <summary>
		/// Starts the web server using the specified web project path. Note 
		/// that the path must be absolute. 
		/// </summary>
		/// <param name="webApplicationAbsolutePath">The web application absolute path.</param>
		public static void StartWebServer(string webApplicationAbsolutePath)
		{
			if (!Directory.Exists(webApplicationAbsolutePath))
			{
				throw new ApplicationException("Cannot start web server as the path could not be found. " + 
					"Check if the following folder exists: " + webApplicationAbsolutePath);
			}

			server = new Server(88, VirtualDir, webApplicationAbsolutePath);
			server.Start();

			started = true;
		}
Exemplo n.º 6
0
 public void Start()
 {
     _server = new Server(_port, "/", _path);
     _server.Start();
 }
Exemplo n.º 7
0
        void Start()
        {
            _appPath = appDirTextBox.Text;
            if (_appPath.Length == 0 || !Directory.Exists(_appPath)) {
                ShowError("Invalid Application Directory");
                appDirTextBox.SelectAll();
                appDirTextBox.Focus();
                return;
            }

            _portString = portTextBox.Text;
            int portNumber = -1;
            try {
                portNumber = Int32.Parse(_portString);
            }
            catch {
            }
            if (portNumber <= 0) {
                ShowError("Invalid Port");
                portTextBox.SelectAll();
                portTextBox.Focus();
                return;
            }

            _virtRoot = vrootTextBox.Text;
            if (_virtRoot.Length == 0 || !_virtRoot.StartsWith("/")) {
                ShowError("Invalid Virtual Root");
                vrootTextBox.SelectAll();
                vrootTextBox.Focus();
                return;
            }

            try {
                _server = new Server(portNumber, _virtRoot, _appPath);
                _server.Start();
            }
            catch {
                ShowError(
                    "Cassini Managed Web Server failed to start listening on port " + portNumber + ".\r\n" +
                    "Possible conflict with another Web Server on the same port.");
                portTextBox.SelectAll();
                portTextBox.Focus();
                return;
            }

            startButton.Enabled = false;
            appDirTextBox.Enabled = false;
            portTextBox.Enabled = false;
            vrootTextBox.Enabled = false;
            browseLabel.Visible = true;
            browseLink.Text = GetLinkText();
            browseLink.Visible = true;
            browseLink.Focus();
        }
Exemplo n.º 8
0
 public static void InitializeBrowser()
 {
     WebServer = new Server(Port, "/", WebSiteFileLocation.get_physical_path());
     
     WebServer.Start();            
 }
Exemplo n.º 9
0
        private void CassiniServer_Load(object sender, EventArgs e)
        {
            try
            {
                this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);

                Random random = new Random();
                Port = random.Next(1000, 65535);
                virtualPath = "/";
                physicalPath = Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("\\"));
                server = new Server(Port, VirtualPath, PhysicalPath);
                server.Start();

                linkLabel1.Text = "http://localhost:" + port;
                textBox1.Text = port.ToString();
                textBox2.Text = virtualPath;
                textBox3.Text = physicalPath;
                linkLabel1_LinkClicked(null, null);

                notifyIcon1.Text = physicalPath;

                this.Visible = false;
                this.notifyIcon1.Visible = true;

                this.notifyIcon1.BalloonTipIcon = ToolTipIcon.Info;
                this.notifyIcon1.BalloonTipTitle = physicalPath;
                this.notifyIcon1.BalloonTipText = "http://localhost:" + port;
                this.notifyIcon1.ShowBalloonTip(2000);
            }
            catch(Exception ex)
            {
                // MessageBox.Show(this, "请将该文件考到网站的Bin目录在运行", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                // button1_Click(sender, e);
                MessageBox.Show(this, ex.ToString(), "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                button1_Click(sender, e);
            }
        }
Exemplo n.º 10
0
        public static void initialise_local_Web_server()
        {
            WebServer = new Server(Port, "/", WebSiteFileLocation.get_physical_path());

            WebServer.Start();
        }