From 5c48e81f6785e30978ef536173a2f3959cba83bd Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 17 Sep 2010 09:48:01 -0700 Subject: [PATCH 1/6] Give a little more feedback on the websocket server --- script/websocket_server.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/script/websocket_server.rb b/script/websocket_server.rb index 8c466ca77..7dee8d35c 100644 --- a/script/websocket_server.rb +++ b/script/websocket_server.rb @@ -35,6 +35,7 @@ end ws.onclose { Diaspora::WebSocket.unsubscribe(ws.request['Path'].gsub('/',''), sid) } } end + puts "Websocket server started." process_message } From 99ad001d28bcd5875af4dbfe356641a9f6524b1d Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 17 Sep 2010 09:52:31 -0700 Subject: [PATCH 2/6] Fix websocket spec, take out puts in by_webfinger --- app/models/person.rb | 2 +- spec/lib/websocket_spec.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 48e8b0816..ac4a5dfa7 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -85,7 +85,7 @@ class Person local_person elsif !identifier.include?("localhost") && !opts[:local] begin - puts "begin finger" + Rails.logger.info("Webfingering #{identifier}") f = Redfinger.finger(identifier) rescue SocketError => e raise "Diaspora server for #{identifier} not found" if e.message =~ /Name or service not known/ diff --git a/spec/lib/websocket_spec.rb b/spec/lib/websocket_spec.rb index 233f7be48..762a725b5 100644 --- a/spec/lib/websocket_spec.rb +++ b/spec/lib/websocket_spec.rb @@ -17,8 +17,9 @@ describe Diaspora::WebSocket do end it 'The queued job should reach Magent' do - Magent.should_receive(:push) @post.socket_to_uid(@user.id, :aspect_ids => @aspect.id) + channel = Magent::GenericChannel.new('websocket') + channel.message_count.should == 1 end end From 511a4487de43e8e56b4d871d9508a605b7cbf866 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 17 Sep 2010 10:44:15 -0700 Subject: [PATCH 3/6] Make running the websocket server a little easier --- script/server | 5 +++++ script/websocket_server.rb | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100755 script/server diff --git a/script/server b/script/server new file mode 100755 index 000000000..0094482b1 --- /dev/null +++ b/script/server @@ -0,0 +1,5 @@ +#!/bin/bash + +mkdir -p -v log/thin/ +bundle exec ruby ./script/websocket_server.rb& +bundle exec thin start $@ diff --git a/script/websocket_server.rb b/script/websocket_server.rb index 7dee8d35c..2fbc1370a 100644 --- a/script/websocket_server.rb +++ b/script/websocket_server.rb @@ -19,6 +19,7 @@ def process_message end +begin EM.run { Diaspora::WebSocket.initialize_channels @@ -35,7 +36,13 @@ end ws.onclose { Diaspora::WebSocket.unsubscribe(ws.request['Path'].gsub('/',''), sid) } } end + puts "Websocket server started." process_message } - +rescue RuntimeError => e + raise e unless e.message.include?("no acceptor") + puts "Are you sure the websocket server isn't already running?" + puts "Just start thin with bundle exec thin start." + Process.exit +end From be26794e4a5e25537aef7a79885014f5bfeb8df2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 17 Sep 2010 10:46:14 -0700 Subject: [PATCH 4/6] only write to your own profile --- app/controllers/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4a36672bc..dc25b47be 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -23,7 +23,7 @@ class UsersController < ApplicationController end def update - @user = User.find_by_id params[:id] + @user = current_user prep_image_url(params[:user]) @user.update_profile params[:user] From 5df33a6fd0dd8b87b1e8527b3c9b112fba7b734a Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 17 Sep 2010 10:50:18 -0700 Subject: [PATCH 5/6] Take out users/show, use current_user in update --- app/controllers/users_controller.rb | 7 ------- config/routes.rb | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index dc25b47be..72666bc30 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -7,13 +7,6 @@ class UsersController < ApplicationController before_filter :authenticate_user!, :except => [:new, :create] respond_to :html - respond_to :json, :only => :show - - def show - @user = User.find_by_id params[:id] - @user_profile = @user.person.profile - respond_with @user - end def edit @user = current_user diff --git a/config/routes.rb b/config/routes.rb index 12dd20ba7..188c4b137 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,7 +6,7 @@ Diaspora::Application.routes.draw do resources :people, :only => [:index, :show, :destroy] - resources :users, :except => [:create, :new] + resources :users, :except => [:create, :new, :show] resources :status_messages, :only => [:create, :destroy, :show] resources :comments, :except => [:index] resources :requests, :except => [:edit, :update] From 3859f8a529b7ec49967f86282d82f10919c568ef Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 17 Sep 2010 10:56:42 -0700 Subject: [PATCH 6/6] Adding instructions to readme --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d941ac182..2398be5dc 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ You are welcome to contribute, add and extend Diaspora however you see fit. We We need you to fill out a [contributor agreement form](https://spreadsheets.google.com/a/joindiaspora.com/viewform?formkey=dGI2cHA3ZnNHLTJvbm10LUhXRTJjR0E6MQ&theme=0AX42CRMsmRFbUy1iOGYwN2U2Mi1hNWU0LTRlNjEtYWMyOC1lZmU4ODg1ODc1ODI&ifq) before we can accept your patches. The agreement gives Diaspora joint ownership of the patch so the copyright isn't scattered. You can find it [here](https://spreadsheets.google.com/a/joindiaspora.com/viewform?formkey=dGI2cHA3ZnNHLTJvbm10LUhXRTJjR0E6MQ&theme=0AX42CRMsmRFbUy1iOGYwN2U2Mi1hNWU0LTRlNjEtYWMyOC1lZmU4ODg1ODc1ODI&ifq). -All commits must be tested, and after each commit, all tests should be green before a pull request is sent. Please write your tests in Rspec or Test-Unit. +All commits must be tested, and after each commit, all tests should be green before a pull request is sent. Please write your tests in Rspec. GEMS: We would like to keep external dependencies unduplicated. We're using Nokogiri, and Mongomapper, and EM::HttpRequest as much as possible. We have a few gems in the project we'd rather not use, but if you can, use dependencies we already have. @@ -195,9 +195,15 @@ If you installed the OsX package through "brew", MongoDB will need to be started Diaspora will not run unless mongo is running. Mongo will not run by default, and will need to be started every time you wish to use or run the test suite for Diaspora. +### Run the server +`./script/server` will start both thin and the websocket server. If you want to run a different app server, you will have to run them separately. See below for instructions. + ### Run the app server Once mongo is running and bundler has finished, run `bundle exec thin start` from the root Diaspora directory. This will start the app server in development mode[.](http://bit.ly/9mwtUw) +### Run the websocket server +run `bundle exec ruby ./script/websocket_server` to start the websocket server on port 8080. Change the port in config/app_config.yml. + ### Logging in Run `rake db:seed:tom`, then login with user `tom` and password `evankorth`. More details in db/seeds/tom.rb.