jamesdconklin / OnceUponATable

Web App providing a basic Virtual Tabletop.
https://onceuponatable.herokuapp.com
3 stars 0 forks source link

General deployment help. #1

Open frshbeetz opened 7 years ago

frshbeetz commented 7 years ago

I cloned your repo, then installed rvm, nodejs, postgresql. When I go to run bin/setup, it says it completes successfully, and the spring server is running, but I don't see anything listening on a public port. Feel free to let me know what information I can provide you with.

Some sample output is below:


~/OnceUponATable/bin$ ./setup
== Installing dependencies ==
The Gemfile's dependencies are satisfied

== Preparing database ==
Running via Spring preloader in process 4777
onceupon already exists
-- enable_extension("plpgsql")
   -> 0.0200s
-- create_table("assets", {:force=>:cascade})
   -> 0.0160s
-- add_index("assets", ["title"], {:name=>"index_assets_on_title", :using=>:btree})
   -> 0.0040s
-- create_table("game_signups", {:force=>:cascade})
   -> 0.0067s
-- add_index("game_signups", ["game_id"], {:name=>"index_game_signups_on_game_id", :using=>:btree})
   -> 0.0032s
-- add_index("game_signups", ["user_id"], {:name=>"index_game_signups_on_user_id", :using=>:btree})
   -> 0.0030s
-- create_table("games", {:force=>:cascade})
   -> 0.0084s
-- add_index("games", ["current_player"], {:name=>"index_games_on_current_player", :using=>:btree})
   -> 0.0033s
-- add_index("games", ["system"], {:name=>"index_games_on_system", :using=>:btree})
   -> 0.0031s
-- add_index("games", ["title"], {:name=>"index_games_on_title", :using=>:btree})
   -> 0.0033s
-- add_index("games", ["user_id"], {:name=>"index_games_on_user_id", :using=>:btree})
   -> 0.0032s
-- create_table("messages", {:force=>:cascade})
   -> 0.0071s
-- add_index("messages", ["game_id"], {:name=>"index_messages_on_game_id", :using=>:btree})
   -> 0.0031s
-- add_index("messages", ["user_id"], {:name=>"index_messages_on_user_id", :using=>:btree})
   -> 0.0031s
-- create_table("users", {:force=>:cascade})
   -> 0.0066s
-- add_index("users", ["username"], {:name=>"index_users_on_username", :using=>:btree})
   -> 0.0030s
-- initialize_schema_migrations_table()
   -> 0.0310s

== Removing old logs and tempfiles ==

== Restarting application server ==

~# ps aux | grep spring
xxxxx+  4648  0.0  2.3 300452 24072 pts/0    Sl   07:19   0:00 spring server | OnceUponATable | started 11 mins ago
xxxxx+  4651  0.4  8.1 494048 83072 ?        Ssl  07:19   0:02 spring app    | OnceUponATable | started 11 mins ago | development mode                                        
root      4795  0.0  0.0  11128   984 pts/1    S+   07:31   0:00 grep spring

~# netstat -uplnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      374/sshd
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      2616/postgres
tcp6       0      0 :::22                   :::*                    LISTEN      374/sshd
tcp6       0      0 ::1:5432                :::*                    LISTEN      2616/postgres
udp        0      0 xx.xxx.xxx.xxx:123         0.0.0.0:*                           394/ntpd
udp        0      0 127.0.0.1:123           0.0.0.0:*                           394/ntpd
udp        0      0 0.0.0.0:123             0.0.0.0:*                           394/ntpd
udp6       0      0 xxxxxxx:xxxxxxx: :::*                                394/ntpd
udp6       0      0 ::1:123                 :::*                                394/ntpd
udp6       0      0 :::123                  :::*                                394/ntpd
frshbeetz commented 7 years ago

Quick update: I've run bin/rails and I see a server listening on 127.0.0.1:3000. So I set up nginx really quick to proxy there, but when I load the site, it's just a white screen.

Log output from rails:


~/OnceUponATable/bin$ ./rails server
=> Booting WEBrick
=> Rails 4.2.7.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2016-11-25 07:41:00] INFO  WEBrick 1.3.1
[2016-11-25 07:41:00] INFO  ruby 2.3.1 (2016-04-26) [x86_64-linux]
[2016-11-25 07:41:00] INFO  WEBrick::HTTPServer#start: pid=4870 port=3000

Started GET "/" for 127.0.0.1 at 2016-11-25 07:41:14 +0000
  ActiveRecord::SchemaMigration Load (0.4ms)  SELECT "schema_migrations".* FROM "schema_migrations"
Processing by StaticPagesController#root as HTML
  User Load (0.7ms)  SELECT  "users".* FROM "users" WHERE "users"."session_token" IS NULL LIMIT 1
  Rendered static_pages/root.html.erb within layouts/application (20.8ms)
Completed 200 OK in 298ms (Views: 296.9ms | ActiveRecord: 1.4ms)
jamesdconklin commented 7 years ago

I use webpack to bundle all my front-end code. If the final bundle.js isn't available, then React never gets around to building the app on the client side.

Try running npm -install from the top directory and running webpack to generatate bundle.js.

jamesdconklin commented 7 years ago

Also as a quick heads up, you'll need to set up your own API keys with figaro. As is right now, neither pusher nor cloudinary will work.

frshbeetz commented 7 years ago

Awesome, thanks! I can confirm that after running:

sudo npm install webpack -g
webpack
./bin/setup
./bin/rails server

That the interface does indeed load when I hit the site, hooray progress!

What kind of headaches am I looking at if I want to use some arbitrary webserver of mine for housing token and map files, instead of cloudinary?

jamesdconklin commented 7 years ago

You'll just need to swap out the logic building URLs and image elements from Cloudinary public_ids with source URLs pointing to your own image assets. If you want to do away with the Pusher API, I imagine you'll need to build your own publish/subscribe model with websockets.

frshbeetz commented 7 years ago

Understood! In the interest of testing further, I've signed up for free Pusher and Cloudinary accounts.

I've been looking over the code a bit, and I can't nail down where should I be inserting these keys.

I read one of your comments about how keys shouldn't be included in the source. Figaro somehow sets them as environment variables then I take it, what should I be looking to do order to configure/run that? Update: Looking over https://github.com/laserlemon/figaro

Presumably, I can also write a bash script to set the variables for testing. If so what are the names of the variables I'll be setting?

My apologies for the onslaught of noob questions, finding a self-hostable grid that my friends and I can drop maps/tokens on has been tricky, since most of the similar projects on here seem thoroughly dead. I'm really stoked to have found one that's being actively developed.

In the meantime, I'll continue to wander around your source code and attempt to answer these questions for myself, will post an update in the event that I figure it out beforehand. Once I can get a version that runs, I might be able to work on some theming and CSS with you in return for the support!

frshbeetz commented 7 years ago

I think i have this working for the most part. I noticed that If I go to add users from my instance of the game I can see them from yours though, which is interesting. I'll let you know if I get stuck anywhere or notice anything else.

jamesdconklin commented 7 years ago

Before you sign on full-throttle, I'd like to point out that this is largely a project undertaken to learn a few technologies and demonstrate them as part of my skillset. While I will be getting around to various enhancements when I've time, it's unlikely to ever be a solid replacement for a site like roll20.

As for the pre-seeded users, that's expected. There is a seeds.rb file that will preseed a project's database. If you wish to have a clean slate, remove or empty the file.

In the meantime, I'm going to keep this issue open until such time as I've updated the readme with setup instructions. I will take note of a need to allow alternate schemes for image hosting and push notifications. It should be noted that the choice to go for pusher was made more out of time pressure and simplicity than any other criterion.

frshbeetz commented 7 years ago

heh understood! Definitely aware of the pitfalls and appreciate your work, as well as your advice. I'll definitely be hacking on it a bit (with my limited abilities) just to mess around, and I'll try to run a game or two to see how it goes.

I've been able to deploy it to a state where a friend of mine can join a game and we can both add tokens, move them etc... so whatever I managed to cobble together does appear to work at least. It sits nicely in an iframe next to another div with my mattermost (rich chat) deployment after some nginx tweaking, so my group has something we'd certainly be able to play around with for now.

Thank you for your time!

I'll look over my notes and add them here as far as what I had to do to deploy on a Debian 8 box with Nginx.

frshbeetz commented 7 years ago

houseparty

I've been hacking up your seeds.rb and stylesheets for our Shadowrun game. Definitely enjoying myself! Just figured I'd show you what it's looking like. :)

frshbeetz commented 7 years ago

How to get this working in Debian 8 / Nginx

Hopefully I didn't miss anything!

Basic Packages

sudo apt-get update ; sudo apt-get upgrade
sudo apt-get install nginx screen postgresql-9.4 postgresql-client-9.4 build-essential git

Installing OnceUponaTable

git clone https://github.com/jamesdconklin/OnceUponATable.git
cd OnceUponATable

RVM and NodeJS

RVM

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable --ruby=jruby --gems=rails,puma
rvm install ruby-2.3.1
rvm use ruby-2.3.1
gem install bundler
sudo apt-get install libpq-dev
gem install pg -v '0.19.0'
bundler

NPM/NODEJS

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm install webpack -g
npm install
webpack

Configuration

Database

sudo su -
su - postgres
creatdb onceupon
createuser --interactive
psql
alter user "tableadmin" with password 'yoursecurepassword';
grant all on database onceupon to tableadmin;
\q

Contents of ~/OnceUponATable/config/database.yml

default: &default
  adapter: postgresql
  encoding: unicode
  pool: 5

development:
  <<: *default
  database: onceupon
  username: tableadmin
  password: yoursecurepassword
  host: localhost
  port: 5432
  template: template0

test:
  <<: *default
  database: onceupon_test

Sign up for the following free services to acquire API Keys

https://cloudinary.com/users/register/free https://pusher.com/signup

Acquire Keys

https://cloudinary.com/console/settings/security https://dashboard.pusher.com/apps/(yourappid)/keys

Contents of ~/OnceUponATable/config/application.yml

PUSHER_APP_ID: ""
PUSHER_API_KEY: 
PUSHER_SECRET: 

#CLOUDINARY_CLOUD_NAME: jdc-asset-server
CLOUDINARY_CLOUD_NAME:
CLOUDUNARY_API_KEY:

Nginx HTTP Config

(I recommed reviewing the CertBot Github repo and Nginx docs for HTTPS)

Contents of /etc/nginx/sites-available/default

server {
       listen         80;
       server_name    YOUR_FQDN_OR_IP;
        location / {
                proxy_pass         http://127.0.0.1:3000;
                proxy_read_timeout 90;
        }
}

sudo service nginx restart

Running the server

cd  ~/OnceUponATable/bin/
./setup
./rails server

Customising

Be sure to have a look at these files:

~/OnceUponATable/db/seeds.rb

~/OnceUponATable/app/assets/stylesheets/canvas.scss