Commits

Michael Granger  committed 13f18a8

Convert to an Angular.js app
* * *
Work from gont

  • Participants
  • Parent commits 47b947d

Comments (0)

Files changed (57)

-RUBYOPT="-Ilib"
+MONGREL2=/Users/mgranger/source/C/mongrel2/bin/mongrel2
+STRELKA_DATADIR=/Users/mgranger/source/ruby/Strelka/data
+FANCYERRORS_DATADIR=/Users/mgranger/source/ruby/Strelka-FancyErrors/data/strelka-fancyerrors
+RUNMODE=development
+RUBYOPT=-I/Users/mgranger/source/ruby/Strelka-FancyErrors/lib:/Users/mgranger/source/ruby/Strelka/lib:/Users/mgranger/source/ruby/Mongrel2/lib
+concurrency: configservice=1,adminmongrel=1,controlservice=1
 \.sqlite$
 ^pkg/
 \.DS_Store
+^logs/
-mongrel: m2sh.rb -c mongrel2.sqlite start
-events: data/strelka-admin/apps/admin-eventserver
-configservice: data/strelka-admin/apps/config-service
+publicmongrel: /Users/mgranger/source/ruby/Mongrel2/bin/m2sh.rb -s -c etc/config.sqlite start main
+adminmongrel: /Users/mgranger/source/ruby/Mongrel2/bin/m2sh.rb -c etc/config.sqlite start strelka-admin
+# events: strelka -c etc/config.yml start admin-eventserver
+configservice: /Users/mgranger/source/ruby/Strelka/bin/strelka -l debug -c etc/config.yml start config-service
+controlservice: /Users/mgranger/source/ruby/Strelka/bin/strelka -l debug -c etc/config.yml start control-service
 

File Strelka-Admin.esproj/Project.espressostorage

Binary file added.

File Strelka-Admin.esproj/user.mgranger.espressostorage

Binary file added.

File data/demo/root/logs/access.log

+84:15:www.example.com,9:127.0.0.1,5:63005#10:1342154569#3:GET,1:/,8:HTTP/1.1,3:404#1:0#]
+96:15:www.example.com,9:127.0.0.1,5:63006#10:1342154569#3:GET,12:/favicon.ico,8:HTTP/1.1,3:404#1:0#]
+95:15:www.example.com,9:127.0.0.1,5:63009#10:1342154576#3:GET,11:/index.html,8:HTTP/1.1,3:404#1:0#]
+96:15:www.example.com,9:127.0.0.1,5:63010#10:1342154576#3:GET,12:/favicon.ico,8:HTTP/1.1,3:404#1:0#]

File data/demo/root/logs/error.log

+Fri, 13 Jul 2012 04:42:14 GMT [INFO] (src/unixy.c:83) Now running as UID:2053, GID:20
+Fri, 13 Jul 2012 04:42:14 GMT [INFO] (src/server.c:271) Starting 0MQ with 1 threads.
+Fri, 13 Jul 2012 04:42:14 GMT [INFO] (src/request.c:57) MAX limits.header_count=1280
+Fri, 13 Jul 2012 04:42:14 GMT [INFO] (src/connection.c:999) MAX limits.content_length=20480, limits.buffer_size=4096, limits.connection_stack_size=32768, limits.client_read_retries=5
+Fri, 13 Jul 2012 04:42:14 GMT [INFO] (src/connection.c:1005) MAX limits.proxy_read_retries=100, limits.proxy_read_retry_warn=10
+Fri, 13 Jul 2012 04:42:14 GMT [INFO] (src/task/fd.c:153) MAX limits.fdtask_stack=102400
+Fri, 13 Jul 2012 04:42:14 GMT [INFO] (src/control.c:423) Setting up control socket in at ipc://run/control
+Fri, 13 Jul 2012 04:42:15 GMT [INFO] (src/mongrel2.c:279) -- Mongrel2/1.7.5 Running. Copyright (C) Zed A. Shaw. Licensed BSD.
+Fri, 13 Jul 2012 04:42:49 GMT [ERROR] (src/dir.c:357: errno: None) Failed to normalize base path: data/demo/www/
+Fri, 13 Jul 2012 04:42:49 GMT [ERROR] (src/dir.c:410: errno: None) Failed to normalize base path when requesting /
+Fri, 13 Jul 2012 04:44:29 GMT [INFO] (src/mongrel2.c:95) SHUTDOWN REQUESTED: MURDER
+Fri, 13 Jul 2012 04:44:29 GMT [ERROR] (src/task/net.c:235: errno: Bad file descriptor) Failed to accept after doing a poll on the socket.
+Fri, 13 Jul 2012 04:44:29 GMT [ERROR] (src/server.c:288: errno: None) Failed to accept on listening socket.
+Fri, 13 Jul 2012 04:44:29 GMT [INFO] (src/mongrel2.c:425) Server run exited, goodbye.
+Fri, 13 Jul 2012 04:44:29 GMT [ERROR] (src/control.c:92: errno: None) Receive on control failed.
+Fri, 13 Jul 2012 04:44:29 GMT [ERROR] (src/control.c:435: errno: None) Failed to read message: Undefined error: 0.
+Fri, 13 Jul 2012 04:44:29 GMT [INFO] (src/control.c:460) Control port exiting with error.
+Fri, 13 Jul 2012 04:44:29 GMT [INFO] (src/mongrel2.c:365) Shutdown requested, goodbye.
+Fri, 13 Jul 2012 04:44:29 GMT [INFO] (src/mongrel2.c:312) Shutting down all running tasks as gracefully as possible.
+Fri, 13 Jul 2012 04:44:29 GMT [INFO] (src/mongrel2.c:320) Tasks now running (including main task): 1
+Fri, 13 Jul 2012 04:44:29 GMT [INFO] (src/mongrel2.c:330) Removing pid file /run/mongrel2.pid

File data/demo/support/index.html

+<html>
+<head>
+	<title>Support Site</title>
+</head>
+<body>
+
+	<header>
+		<h1>Example Support</h1>
+	</header>
+
+	<p>This is the example support site for example.com.</p>
+
+</body>
+</html>

File data/demo/www/index.html

+<html>
+<head>
+	<title>Main Site</title>
+</head>
+<body>
+
+	<header>
+		<h1>Example!</h1>
+	</header>
+
+	<p>This is the main site for www.example.com.</p>
+
+</body>
+</html>

File data/strelka-admin/app.conf

-templates:
-  template_paths:
-    - /Users/mgranger/source/ruby/Strelka/data/strelka/templates
-
-mongrel2:
-  configdb: data/strelka/strelka.sqlite
-

File data/strelka-admin/apps/config-service

 #!/usr/bin/env ruby
 
+require 'configurability'
 require 'strelka'
 require 'strelka/admin'
 require 'uuidtools'
 class Strelka::ConfigService < Strelka::App
 	extend Configurability
 
+
 	# The version of this service API -- used in determining the
 	# versioned route. If this changes in a non-backward compatible way,
 	# this should be incremented
 	APIVERSION = 1
 
 	# The 'appid' of the route to point the application at
-	ID = Strelka::Admin::CONFIGSERVICE_ID
+	ID = 'config-service'
 
 	# Load some plugins
 	plugins :restresources, :templating
 	# templates \
 	#	:overview => 'configservice/overview.tmpl'
 
-	param :id, :integer
-	param :uuid, :string
 
 	# GET /uuid -- fetch a plain-text random UUID
 	get '/uuid' do |req|
 	end
 
 
+	get '/uri' do |req|
+		res = req.response
+		path = Mongrel2::Config.db.url
+
+		res.for( :text, :yaml, :json ) {[ path.to_s ]}
+		res.for( :html ) do
+			tmpl = self.template( :message )
+			tmpl.message = path
+			self.log.debug "Returning message template: %p" % [ tmpl ]
+			tmpl
+		end
+
+		return res
+	end
+
 	#
 	# Config Service API
 	#
 
-	resource Mongrel2::Config::Server
-	resource Mongrel2::Config::Host
-	resource Mongrel2::Config::Route
-	resource Mongrel2::Config::Setting
-	resource Mongrel2::Config::Filter
-	resource Mongrel2::Config::Mimetype
+
+	### Configurability API -- install routes for the model classes when the config
+	### is loaded, as Sequel::Model bitches if it doesn't have a database handle yet.
+	def self::configure( config )
+		super
+
+		resource Mongrel2::Config::Directory
+		resource Mongrel2::Config::Filter
+		resource Mongrel2::Config::Handler
+		resource Mongrel2::Config::Host
+		resource Mongrel2::Config::Log
+		resource Mongrel2::Config::Mimetype
+		resource Mongrel2::Config::Proxy
+		resource Mongrel2::Config::Route
+		resource Mongrel2::Config::Server
+		resource Mongrel2::Config::Setting
+
+	end
 
 end # class Strelka::ConfigService
 
+Encoding.default_internal = Encoding::UTF_8
+Strelka::ConfigService.run if __FILE__ == $0
 
-if __FILE__ == $0
-	Strelka.load_config( 'etc/config.yml' )
-	Strelka::ConfigService.run
-end
-
-
-
-

File data/strelka-admin/apps/control-service

+#!/usr/bin/env ruby
+
+require 'strelka'
+require 'strelka/admin'
+
+# The Strelka-Admin REST service for the Mongrel2 control socket.
+class Strelka::ControlService < Strelka::App
+
+	# The version of this service API -- used in determining the
+	# versioned route. If this changes in a non-backward compatible way,
+	# this should be incremented
+	APIVERSION = 1
+
+	# The 'appid' of the route to point the application at
+	ID = 'control-service'
+
+	# Load some plugins
+	plugins :negotiation, :parameters, :routing, :templating
+
+	# By default, responses are HTML
+	default_type 'text/html'
+
+	# Templating -- wrap human-viewable stuff in a consistent layout
+	layout 'layout.tmpl'
+	templates \
+		:info => 'controlservice/info.tmpl'
+
+
+	param :serverid, /^([a-z][\w\-]+)$/i, "Server ID", :untaint
+
+
+
+	# GET /«serverid»
+	get '/:serverid' do |req|
+		finish_with( HTTP::BAD_REQUEST, req.params.errors.join("\n") ) unless req.params.okay?
+		uuid = req.params[:serverid]
+
+		server = Mongrel2::Config::Server.by_uuid( uuid ).first or
+			finish_with( HTTP::NOT_FOUND, "No such server %p" % [uuid] )
+		control = server.control_socket
+		data = control.info
+		res = req.response
+
+		res.for( :html ) do |res|
+			tmpl = self.template( :info )
+			tmpl.info = data.first
+			tmpl
+		end
+		res.for( :json, :yaml ) { data }
+
+
+		return res
+	end
+
+
+end # class Strelka::ConfigService
+
+Encoding.default_internal = Encoding::UTF_8
+Strelka::ControlService.run if __FILE__ == $0
+

File data/strelka-admin/host-config.rb

-#!/usr/bin/env ruby
-
-require 'pathname'
-
-require 'mongrel2/config'
-include Mongrel2::Config::DSL
-
-require 'strelka'
-require 'strelka/constants'
-include Strelka::Constants
-
-# Load the app classes to grab their appids. Only necessary for bootstrapping.
-adminapp = Strelka::App.load( DATADIR + 'apps/strelka-admin' ).first
-helloapp = Strelka::App.load( DATADIR + 'apps/hello-world' ).first
-
-# This is the config that's loaded by 'leash setup' to get the admin server
-# up and running.
-server ADMINSERVER_ID do
-    name 'Strelka Admin Server'
-	port 8833
-	chroot '.'
-	access_log '/logs/admin-access.log'
-	error_log '/logs/admin-error.log'
-	pid_file '/run/admin.pid'
-	bind_addr '127.0.0.1'
-
-	default_host 'localhost'
-
-    host 'localhost' do
-        route '/', handler( 'tcp://127.0.0.1:19999', adminapp.default_appid )
-        route '/hello', handler( 'tcp://127.0.0.1:19995', helloapp.default_appid )
-
-		route '/css',    directory( 'static/css/', 'base.css', 'text/css' )
-		route '/images', directory( 'static/images/' )
-		route '/fonts',  directory( 'static/fonts/' )
-		route '/js',     directory( 'static/js/', 'index.js', 'text/javascript' )
-    end
-end
-
-setting "control_port", 'ipc://run/control'
-
-mimetypes '.ttf' => 'application/x-font-truetype',
-          '.otf' => 'application/x-font-opentype'
-

File data/strelka-admin/static/css/master.css

-/* @override http://localhost:7337/css/master.css
-	http://localhost:8113/css/master.css */
+/* @override 
+	http://localhost:8080/css/master.css */
+
+/* 
+ * Strelka Admin Console main stylesheet
+ */
 
 @import url(/css/bootstrap.css);
 body {
 	padding-top: 60px;
 	padding-bottom: 40px;
 }
-.sidebar-nav {
-	padding: 9px 0;
-}
 @import url(/css/bootstrap-responsive.css);
 
 
 	font: 14px/18px IstokWeb;
 }
 
-div.container-fluid > footer {
+html > footer {
 	color: #999;
+}
+
+section + span.ng-scope + section {
+	margin-top: 2em;
+	
+}
+
+.server-list {
+	background: #efefef;
+	cursor: pointer;
+}
+
+ul.event-log {
+	background-color: #f5f5f5;
+	list-style-type: none;
+	margin: 0;
+	padding: 8px 4px;
+}
+ul.event-log li {
+	line-height: 1.66;
+	margin-left: 16px;
+	text-indent: -16px;
+}
+ul.event-log li + li {
+	border-top: 1px solid #ddd;
+}
+
+ul.event-log {
+	color: #666;
+}
+ul.event-log .happened-at:before {
+	content:  "[";
+}
+ul.event-log .happened-at:after {
+	content:  "]";
+}
+ul.event-log .how:before {
+	content: "«";
+}
+ul.event-log .how:after {
+	content: "»";
+}
+ul.event-log .how {
+	font-family: monospace;
+	padding: 0 0.5em;
+}
+ul.event-log .who, ul.event-log .location {
+	font-style: italic;
+}
+ul.event-log .location:before {
+	content: "@";
+}
+ul.event-log .what {
+	color: black;
 }