game_machine 0.0.11 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +12 -1
- data/Gemfile.lock +32 -47
- data/Rakefile +0 -27
- data/bin/bundle_run.sh +1 -0
- data/bin/game_machine +29 -27
- data/config/cluster.conf +6 -5
- data/config/default.conf +164 -0
- data/config/game_machine.sql +33 -0
- data/config/game_messages.proto +87 -25
- data/config/gamecloud.conf +140 -0
- data/config/messages.proto +46 -53
- data/config/test.conf +149 -0
- data/game_machine.gemspec +10 -5
- data/games/boot.rb +3 -0
- data/games/example/data/game_data.yml +4 -4
- data/games/example/lib/aggressive_npc.rb +1 -1
- data/games/example/lib/game.rb +1 -2
- data/games/example/lib/player_register.rb +1 -1
- data/games/routes.rb +9 -0
- data/games/tutorial/boot.rb +12 -0
- data/games/tutorial/item_manager.rb +256 -0
- data/games/tutorial/object_store.rb +55 -0
- data/games/tutorial/seed.rb +52 -0
- data/games/tutorial/sql_store.rb +30 -0
- data/java/project/build.gradle +134 -0
- data/java/project/component.erb +719 -0
- data/java/{gradle.properties → project/gradle.properties} +1 -1
- data/java/project/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/java/{gradle → project/gradle}/wrapper/gradle-wrapper.properties +2 -2
- data/java/{gradlew → project/gradlew} +0 -0
- data/java/{gradlew.bat → project/gradlew.bat} +0 -0
- data/java/project/local_lib/AdminUi.jar +0 -0
- data/java/{local_lib/protostuff-compiler-1.0.7-jarjar.jar → project/local_lib/protostuff-compiler-1.0.8-jarjar.jar} +0 -0
- data/java/project/local_lib/sigar/libsigar-amd64-freebsd-6.so +0 -0
- data/java/project/local_lib/sigar/libsigar-amd64-linux.so +0 -0
- data/java/project/local_lib/sigar/libsigar-amd64-solaris.so +0 -0
- data/java/project/local_lib/sigar/libsigar-ia64-hpux-11.sl +0 -0
- data/java/project/local_lib/sigar/libsigar-ia64-linux.so +0 -0
- data/java/project/local_lib/sigar/libsigar-pa-hpux-11.sl +0 -0
- data/java/project/local_lib/sigar/libsigar-ppc-aix-5.so +0 -0
- data/java/project/local_lib/sigar/libsigar-ppc-linux.so +0 -0
- data/java/project/local_lib/sigar/libsigar-ppc64-aix-5.so +0 -0
- data/java/project/local_lib/sigar/libsigar-ppc64-linux.so +0 -0
- data/java/project/local_lib/sigar/libsigar-s390x-linux.so +0 -0
- data/java/project/local_lib/sigar/libsigar-sparc-solaris.so +0 -0
- data/java/project/local_lib/sigar/libsigar-sparc64-solaris.so +0 -0
- data/java/project/local_lib/sigar/libsigar-universal-macosx.dylib +0 -0
- data/java/project/local_lib/sigar/libsigar-universal64-macosx.dylib +0 -0
- data/java/project/local_lib/sigar/libsigar-x86-freebsd-5.so +0 -0
- data/java/project/local_lib/sigar/libsigar-x86-freebsd-6.so +0 -0
- data/java/project/local_lib/sigar/libsigar-x86-linux.so +0 -0
- data/java/project/local_lib/sigar/libsigar-x86-solaris.so +0 -0
- data/java/project/local_lib/sigar/sigar-amd64-winnt.dll +0 -0
- data/java/project/local_lib/sigar/sigar-x86-winnt.dll +0 -0
- data/java/project/local_lib/sigar/sigar-x86-winnt.lib +0 -0
- data/java/project/model.erb +99 -0
- data/java/{settings.gradle → project/settings.gradle} +0 -0
- data/java/project/src/main/java/com/game_machine/authentication/DefaultAuthenticator.java +28 -0
- data/java/project/src/main/java/com/game_machine/authentication/PlayerAuthenticator.java +6 -0
- data/java/project/src/main/java/com/game_machine/authentication/PublicAuthenticator.java +20 -0
- data/java/{src → project/src}/main/java/com/game_machine/core/ActorFactory.java +0 -0
- data/java/{src → project/src}/main/java/com/game_machine/core/ActorUtil.java +13 -0
- data/java/project/src/main/java/com/game_machine/core/AuthorizedPlayers.java +23 -0
- data/java/project/src/main/java/com/game_machine/core/ClientMessageDecoder.java +36 -0
- data/java/project/src/main/java/com/game_machine/core/ClientMessageEncoder.java +19 -0
- data/java/project/src/main/java/com/game_machine/core/CloudClient.java +298 -0
- data/java/{src → project/src}/main/java/com/game_machine/core/CommandProxy.java +0 -0
- data/java/project/src/main/java/com/game_machine/core/Commands.java +20 -0
- data/java/project/src/main/java/com/game_machine/core/DatastoreCommands.java +43 -0
- data/java/project/src/main/java/com/game_machine/core/DbConnectionPool.java +72 -0
- data/java/project/src/main/java/com/game_machine/core/DefaultMovementVerifier.java +56 -0
- data/java/{src → project/src}/main/java/com/game_machine/core/EntitySerializer.java +0 -0
- data/java/project/src/main/java/com/game_machine/core/EntityTracking.java +119 -0
- data/java/{src → project/src}/main/java/com/game_machine/core/EventStreamHandler.java +1 -1
- data/java/project/src/main/java/com/game_machine/core/GameActor.java +73 -0
- data/java/project/src/main/java/com/game_machine/core/GameMachineLoader.java +43 -0
- data/java/project/src/main/java/com/game_machine/core/GameMessageActor.java +44 -0
- data/java/project/src/main/java/com/game_machine/core/Grid.java +255 -0
- data/java/{src → project/src}/main/java/com/game_machine/core/GridValue.java +0 -0
- data/java/project/src/main/java/com/game_machine/core/Hashring.java +66 -0
- data/java/{src → project/src}/main/java/com/game_machine/core/IActorFactory.java +0 -0
- data/java/project/src/main/java/com/game_machine/core/LocalLinkedBuffer.java +20 -0
- data/java/project/src/main/java/com/game_machine/core/MessageGateway.java +120 -0
- data/java/project/src/main/java/com/game_machine/core/MessagePersister.java +26 -0
- data/java/project/src/main/java/com/game_machine/core/MonoProxy.java +39 -0
- data/java/project/src/main/java/com/game_machine/core/MovementVerifier.java +7 -0
- data/java/{src → project/src}/main/java/com/game_machine/core/NetMessage.java +10 -6
- data/java/project/src/main/java/com/game_machine/core/PersistentMessage.java +9 -0
- data/java/project/src/main/java/com/game_machine/core/PlayerCommands.java +31 -0
- data/java/project/src/main/java/com/game_machine/core/TcpServer.java +100 -0
- data/java/project/src/main/java/com/game_machine/core/TcpServerHandler.java +54 -0
- data/java/project/src/main/java/com/game_machine/core/TcpServerInitializer.java +32 -0
- data/java/project/src/main/java/com/game_machine/core/UdpClient.java +86 -0
- data/java/{src → project/src}/main/java/com/game_machine/core/UdpServer.java +18 -27
- data/java/{src → project/src}/main/java/com/game_machine/core/UdpServerHandler.java +23 -26
- data/java/project/src/main/java/com/game_machine/core/Vector3.java +159 -0
- data/java/project/src/main/java/com/game_machine/orm/models/PlayerItem.java +118 -0
- data/java/project/src/main/java/com/game_machine/orm/models/TestObject.java +110 -0
- data/java/project/src/main/java/com/game_machine/tutorial/LootGenerator.java +26 -0
- data/java/{src → project/src}/main/resources/game_machine.java.stg +3 -1
- data/java/project/src/main/resources/logback.properties +13 -0
- data/java/project/src/main/resources/logback.xml +76 -0
- data/java/{src → project/src}/main/resources/protostuff.properties +0 -0
- data/java/src/main/java/game/MyGameActor.java +26 -0
- data/lib/game_machine.rb +17 -16
- data/lib/game_machine/actor.rb +1 -1
- data/lib/game_machine/actor/base.rb +8 -31
- data/lib/game_machine/actor/builder.rb +5 -6
- data/lib/game_machine/actor/game_actor.rb +55 -0
- data/lib/game_machine/actor/reloadable.rb +6 -1
- data/lib/game_machine/akka.rb +26 -32
- data/lib/game_machine/app_config.rb +39 -26
- data/lib/game_machine/application.rb +56 -62
- data/lib/game_machine/client_manager.rb +14 -8
- data/lib/game_machine/cloud_updater.rb +51 -0
- data/lib/game_machine/cluster_monitor.rb +3 -3
- data/lib/game_machine/commands.rb +1 -1
- data/lib/game_machine/commands/misc_commands.rb +4 -8
- data/lib/game_machine/commands/player_commands.rb +8 -0
- data/lib/game_machine/console.rb +1 -0
- data/lib/game_machine/console/build.rb +57 -24
- data/lib/game_machine/console/bundle.rb +95 -0
- data/lib/game_machine/console/deploy.rb +30 -0
- data/lib/game_machine/console/install.rb +70 -36
- data/lib/game_machine/console/server.rb +2 -69
- data/lib/game_machine/data_store.rb +111 -15
- data/lib/game_machine/data_stores/couchbase.rb +8 -3
- data/lib/game_machine/data_stores/gamecloud.rb +93 -0
- data/lib/game_machine/data_stores/jdbc.rb +98 -0
- data/lib/game_machine/default_handlers.rb +2 -0
- data/lib/game_machine/default_handlers/team_handler.rb +51 -0
- data/lib/game_machine/default_handlers/zone_manager.rb +30 -0
- data/lib/game_machine/endpoints.rb +0 -4
- data/lib/game_machine/endpoints/udp_incoming.rb +13 -5
- data/lib/game_machine/endpoints/udp_outgoing.rb +15 -9
- data/lib/game_machine/game_systems.rb +0 -2
- data/lib/game_machine/game_systems/agents/controller.rb +2 -2
- data/lib/game_machine/game_systems/entity_tracking.rb +0 -3
- data/lib/game_machine/game_systems/region_manager.rb +3 -2
- data/lib/game_machine/game_systems/region_service.rb +2 -2
- data/lib/game_machine/game_systems/remote_echo.rb +10 -0
- data/lib/game_machine/game_systems/team_manager.rb +2 -11
- data/lib/game_machine/grid.rb +5 -18
- data/lib/game_machine/handlers/authentication.rb +1 -9
- data/lib/game_machine/handlers/game.rb +27 -2
- data/lib/game_machine/handlers/player_authentication.rb +87 -0
- data/lib/game_machine/handlers/request.rb +9 -11
- data/lib/game_machine/hocon_config.rb +81 -0
- data/lib/game_machine/java_lib.rb +14 -1
- data/lib/game_machine/logger.rb +10 -23
- data/lib/game_machine/models.rb +1 -0
- data/lib/game_machine/mono_server.rb +6 -1
- data/lib/game_machine/object_db.rb +12 -6
- data/lib/game_machine/protobuf.rb +1 -1
- data/lib/game_machine/protobuf/game_messages.rb +13 -3
- data/lib/game_machine/protobuf/generate.rb +107 -5
- data/lib/game_machine/restart_watcher.rb +1 -1
- data/lib/game_machine/routes.rb +23 -0
- data/lib/game_machine/scheduler.rb +1 -1
- data/lib/game_machine/securerandom.rb +2 -0
- data/lib/game_machine/system_stats.rb +28 -7
- data/lib/game_machine/version.rb +1 -1
- data/lib/game_machine/wavefront_ext.rb +47 -0
- data/lib/game_machine/write_behind_cache.rb +24 -9
- data/mono/server/Makefile +1 -1
- data/mono/server/Newtonsoft.Json.dll +0 -0
- data/mono/server/build.bat +1 -1
- data/mono/server/callable.cs +9 -0
- data/mono/server/echo.cs +17 -0
- data/mono/server/message_router.cs +16 -23
- data/mono/server/messages.cs +1792 -417
- data/mono/server/protobuf-net.dll +0 -0
- data/mono/server/server.cs +120 -0
- data/mono/server/server.exe +0 -0
- data/pathfinding/astar.cpp +149 -0
- data/pathfinding/build.sh +6 -0
- data/pathfinding/build.txt +16 -0
- data/pathfinding/crowd.cpp +194 -0
- data/pathfinding/include/astar.h +49 -0
- data/pathfinding/include/common.h +5 -0
- data/pathfinding/include/crowd.h +43 -0
- data/pathfinding/include/micropather.h +511 -0
- data/pathfinding/include/navmesh.h +114 -0
- data/pathfinding/include/pathfinder.h +24 -0
- data/pathfinding/main.cpp +108 -17
- data/pathfinding/micropather.cpp +1062 -0
- data/pathfinding/navmesh.cpp +408 -0
- data/pathfinding/overrides/DetourCrowd.cpp +1446 -0
- data/pathfinding/overrides/DetourNavMeshQuery.cpp +3551 -0
- data/pathfinding/overrides/DetourNavMeshQuery.h +538 -0
- data/pathfinding/pathfinder.cpp +117 -0
- data/pathfinding/{bin → premake}/premake4 +0 -0
- data/pathfinding/premake/premake4.exe +0 -0
- data/pathfinding/premake4.lua +12 -3
- data/spec/actor/actor_spec.rb +0 -7
- data/spec/client_manager_spec.rb +1 -1
- data/spec/couchproxy_spec.rb +38 -0
- data/spec/entity_persistence_spec.rb +129 -0
- data/spec/game_systems/team_manager_spec.rb +2 -2
- data/spec/hashring_spec.rb +17 -39
- data/spec/java_grid_spec.rb +0 -2
- data/spec/misc_spec.rb +111 -0
- data/spec/mono_spec.rb +50 -3
- data/spec/reliable_message_spec.rb +38 -0
- data/spec/spec_helper.rb +4 -4
- data/spec/spec_helper_minimal.rb +10 -0
- data/web/app.rb +108 -86
- data/web/config/trinidad.yml +1 -0
- data/web/views/add_player.erb +25 -0
- data/web/views/index.erb +0 -0
- data/web/views/layout.erb +48 -0
- data/web/views/login.erb +25 -0
- data/web/views/players.erb +24 -0
- metadata +209 -94
- data/config/config.example.yml +0 -100
- data/config/regions.example.yml +0 -9
- data/games/example/lib/authentication_handler.rb +0 -69
- data/games/models.rb +0 -3
- data/games/models/clan_member.rb +0 -8
- data/games/models/clan_profile.rb +0 -9
- data/games/models/player.rb +0 -7
- data/games/plugins.rb +0 -1
- data/games/plugins/team_handler.rb +0 -49
- data/games/preload.rb +0 -13
- data/java/.gitignore +0 -1
- data/java/build.gradle +0 -95
- data/java/component.erb +0 -396
- data/java/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/java/src/main/java/com/game_machine/core/GameMachineLoader.java +0 -25
- data/java/src/main/java/com/game_machine/core/Grid.java +0 -195
- data/java/src/main/resources/logback.xml +0 -14
- data/java/src/main/resources/logging.properties +0 -3
- data/lib/game_machine/actor/mono_actor.rb +0 -89
- data/lib/game_machine/auth_handlers/base.rb +0 -21
- data/lib/game_machine/auth_handlers/public.rb +0 -34
- data/lib/game_machine/endpoints/mono_gateway.rb +0 -87
- data/lib/game_machine/endpoints/tcp.rb +0 -51
- data/lib/game_machine/endpoints/tcp_handler.rb +0 -75
- data/lib/game_machine/endpoints/udp.rb +0 -88
- data/lib/game_machine/game_loader.rb +0 -46
- data/lib/game_machine/game_systems/region_settings.rb +0 -13
- data/lib/game_machine/hashring.rb +0 -48
- data/lib/game_machine/settings.rb +0 -11
- data/mono/server/actor.cs +0 -37
- data/mono/server/iactor.cs +0 -11
- data/mono/server/message_util.cs +0 -29
- data/mono/server/proxy_client.cs +0 -73
- data/mono/server/proxy_server.cs +0 -30
- data/mono/server/test_actor.cs +0 -33
- data/pathfinding/include/pathfind.h +0 -167
- data/pathfinding/pathfind.cpp +0 -174
- data/pathfinding/pathfinder.cs +0 -66
- data/script/server.sh +0 -109
- data/script/watch.sh +0 -11
- data/spec/commands/navigation_commands_spec.rb +0 -51
- data/spec/game_systems/entity_tracking_spec.rb +0 -64
- data/spec/navigation/detour_navmesh_spec.rb +0 -34
- data/spec/navigation/detour_path_spec.rb +0 -25
- data/spec/udp_server_spec.rb +0 -10
- data/web/controllers/auth_controller.rb +0 -19
- data/web/controllers/base_controller.rb +0 -16
- data/web/controllers/index_controller.rb +0 -7
- data/web/controllers/log_controller.rb +0 -47
- data/web/controllers/messages_controller.rb +0 -59
- data/web/controllers/player_register_controller.rb +0 -15
- data/web/views/game_messages.haml +0 -45
- data/web/views/index.haml +0 -6
- data/web/views/layout.haml +0 -41
- data/web/views/logs.haml +0 -32
- data/web/views/player_register.haml +0 -22
- data/web/views/player_registered.haml +0 -2
- data/web/views/register_layout.haml +0 -22
- data/web/views/restart.haml +0 -35
@@ -0,0 +1,51 @@
|
|
1
|
+
module GameMachine
|
2
|
+
class CloudUpdater < Actor::Base
|
3
|
+
|
4
|
+
attr_reader :node_status, :stats, :windows
|
5
|
+
def post_init(*args)
|
6
|
+
|
7
|
+
@stats = {}
|
8
|
+
@windows = Config::CONFIG['target_os'].match(/mswin/)
|
9
|
+
|
10
|
+
if ENV['CONTAINER_ID'] && ENV['CLUSTER_NAME']
|
11
|
+
@node_status = MessageLib::NodeStatus.new.
|
12
|
+
set_container_id(ENV['CONTAINER_ID'].to_i).
|
13
|
+
set_hostname(AppConfig.instance.config.http.host).
|
14
|
+
set_port(AppConfig.instance.config.http.port).
|
15
|
+
set_cluster_name(ENV['CLUSTER_NAME']).
|
16
|
+
set_client_count(ClientManager.local_players.size)
|
17
|
+
|
18
|
+
schedule_message('update',5,:seconds)
|
19
|
+
end
|
20
|
+
|
21
|
+
cluster = JavaLib::Cluster.get(getContext.system)
|
22
|
+
cluster.subscribe(getSelf, JavaLib::ClusterEvent::ClusterMetricsChanged.java_class)
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def on_receive(message)
|
27
|
+
if message.is_a?(JavaLib::ClusterEvent::ClusterMetricsChanged)
|
28
|
+
message.get_node_metrics.each do |node_metric|
|
29
|
+
heap = JavaLib::StandardMetrics.extract_heap_memory(node_metric)
|
30
|
+
stats[:heap] = heap.used / 1024 / 1024
|
31
|
+
unless windows
|
32
|
+
cpu = JavaLib::StandardMetrics.extract_cpu(node_metric)
|
33
|
+
if cpu.respond_to?(:systemLoadAverage)
|
34
|
+
stats[:load_average] = cpu.systemLoadAverage.get
|
35
|
+
stats[:processor_count] = cpu.processors
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
if message.is_a?(String)
|
41
|
+
if message == 'update'
|
42
|
+
node_status.set_last_updated(Time.now.to_i)
|
43
|
+
node_status.set_client_count(ClientManager.local_players.size)
|
44
|
+
node_status.set_heap_used(stats[:heap])
|
45
|
+
node_status.set_load_average(stats[:load_average])
|
46
|
+
JavaLib::CloudClient.get_instance.update_node_status(node_status)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -72,7 +72,7 @@ module GameMachine
|
|
72
72
|
|
73
73
|
elsif message.is_a?(JavaLib::ClusterEvent::MemberRemoved)
|
74
74
|
address = message.member.address.to_string
|
75
|
-
Akka.instance.hashring.
|
75
|
+
Akka.instance.hashring.remove_node(address)
|
76
76
|
self.class.remove_cluster_member(address)
|
77
77
|
self.class.remove_remote_member(address)
|
78
78
|
|
@@ -83,7 +83,7 @@ module GameMachine
|
|
83
83
|
elsif message.is_a?(JavaLib::ClusterEvent::MemberUp)
|
84
84
|
address = message.member.address.to_string
|
85
85
|
self.class.add_cluster_member(address,message.member)
|
86
|
-
Akka.instance.hashring.
|
86
|
+
Akka.instance.hashring.add_node(address)
|
87
87
|
|
88
88
|
unless address == @cluster.self_address.to_string
|
89
89
|
self.class.add_remote_member(address,message.member)
|
@@ -98,7 +98,7 @@ module GameMachine
|
|
98
98
|
message.get_members.each do |member|
|
99
99
|
address = member.address.to_string
|
100
100
|
self.class.add_cluster_member(address,member)
|
101
|
-
Akka.instance.hashring.
|
101
|
+
Akka.instance.hashring.add_node(address)
|
102
102
|
unless address == @cluster.self_address.to_string
|
103
103
|
self.class.add_remote_member(address,member)
|
104
104
|
end
|
@@ -7,7 +7,7 @@ require_relative 'commands/misc_commands'
|
|
7
7
|
require_relative 'commands/proxy'
|
8
8
|
require_relative 'commands/base'
|
9
9
|
|
10
|
-
if
|
10
|
+
if RbConfig::CONFIG['host_os'].match(/linux/i)
|
11
11
|
require_relative 'commands/navigation_commands'
|
12
12
|
end
|
13
13
|
|
@@ -2,18 +2,14 @@ module GameMachine
|
|
2
2
|
module Commands
|
3
3
|
class MiscCommands
|
4
4
|
|
5
|
-
attr_reader :player_manager
|
5
|
+
attr_reader :player_manager, :mono_proxy
|
6
6
|
def initialize
|
7
|
+
@mono_proxy = JavaLib::MonoProxy.getInstance
|
7
8
|
@player_manager = Application.config.player_manager
|
8
9
|
end
|
9
10
|
|
10
|
-
def
|
11
|
-
|
12
|
-
update = Models::PlayerStatusUpdate.new(:player_id => player_id,:status => status)
|
13
|
-
Actor::Base.find(player_manager).tell(update)
|
14
|
-
else
|
15
|
-
GameMachine.logger.info "player manager not defined."
|
16
|
-
end
|
11
|
+
def call_mono(klass,message)
|
12
|
+
mono_proxy.call(klass,message)
|
17
13
|
end
|
18
14
|
|
19
15
|
def client_manager_register(name,events=[])
|
@@ -3,6 +3,14 @@ module GameMachine
|
|
3
3
|
class PlayerCommands
|
4
4
|
include MessageHelper
|
5
5
|
|
6
|
+
def send_game_message(game_message,player_id)
|
7
|
+
entity = MessageLib::Entity.new.set_id('0')
|
8
|
+
game_messages = MessageLib::GameMessages.new
|
9
|
+
game_messages.add_game_message(game_message)
|
10
|
+
entity.set_game_messages(game_messages)
|
11
|
+
send_message(entity,player_id)
|
12
|
+
end
|
13
|
+
|
6
14
|
def send_message(message,player_id)
|
7
15
|
if player_id.nil?
|
8
16
|
raise "player id cannot be nil"
|
data/lib/game_machine/console.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'fileutils'
|
2
|
-
require_relative '../settings'
|
3
2
|
module GameMachine
|
4
3
|
module Console
|
5
4
|
class Build
|
6
5
|
|
7
|
-
attr_reader :command
|
8
|
-
def initialize(argv)
|
6
|
+
attr_reader :command, :bundle
|
7
|
+
def initialize(argv,bundle=false)
|
8
|
+
@bundle = bundle
|
9
9
|
@command = argv.shift || ''
|
10
10
|
end
|
11
11
|
|
@@ -21,17 +21,21 @@ module GameMachine
|
|
21
21
|
File.join(java_root,'gradlew')
|
22
22
|
end
|
23
23
|
|
24
|
-
def build_code
|
25
|
-
system("cd #{java_root} && #{gradlew} build")
|
26
|
-
end
|
27
|
-
|
28
24
|
def generate_csharp_code
|
29
25
|
protogen_path = File.join(ENV['APP_ROOT'],'mono','bin','csharp','protogen_csharp.exe')
|
30
26
|
proto_file = File.join(ENV['APP_ROOT'],'config','combined_messages.proto')
|
27
|
+
proto_path = File.join(ENV['APP_ROOT'],'config')
|
31
28
|
messages_out_file = File.join(ENV['APP_ROOT'],'messages.cs')
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
|
30
|
+
# Yet another .NET tool that assumes the whole world is windows. In this case it embeds a
|
31
|
+
# windows protoc.exe, so we have to compile differently on non windows platforms
|
32
|
+
if Config::CONFIG['target_os'].match(/mswin/)
|
33
|
+
cmd = "#{protogen_path} -i:#{proto_file} -o:#{messages_out_file}"
|
34
|
+
else
|
35
|
+
bin_out_file = File.join(ENV['APP_ROOT'],'messages.bin')
|
36
|
+
cmd = "protoc -I#{proto_path} #{proto_file} -o#{bin_out_file}; mono #{protogen_path} -i:#{bin_out_file} -o:#{messages_out_file};rm -f #{bin_out_file}"
|
37
|
+
end
|
38
|
+
return cmd
|
35
39
|
end
|
36
40
|
|
37
41
|
def generate_java_code
|
@@ -41,31 +45,60 @@ module GameMachine
|
|
41
45
|
|
42
46
|
def generate_code
|
43
47
|
generate_java_code
|
44
|
-
|
45
|
-
generate_csharp_code
|
46
|
-
end
|
48
|
+
generate_csharp_code
|
47
49
|
end
|
48
50
|
|
49
51
|
def remove_libs
|
50
52
|
FileUtils.rm Dir.glob(File.join(java_lib,'*.jar'))
|
51
53
|
end
|
52
54
|
|
53
|
-
def
|
54
|
-
|
55
|
+
def build(clean=false)
|
56
|
+
if clean
|
57
|
+
cmd = "cd #{java_root} && #{gradlew} clean build install_libs"
|
58
|
+
else
|
59
|
+
cmd = "cd #{java_root} && #{gradlew} build install_libs"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundle_commands
|
64
|
+
gm_path = File.join(ENV['APP_ROOT'],'.game_machine')
|
65
|
+
FileUtils.mkdir_p(gm_path)
|
66
|
+
vendor_path = File.join(gm_path,'vendor','bundle')
|
67
|
+
cmd = "cd #{ENV['APP_ROOT']} && bundle install --path=#{vendor_path}"
|
68
|
+
end
|
69
|
+
|
70
|
+
def run_commands(commands)
|
71
|
+
commands.each do |command|
|
72
|
+
system(command)
|
73
|
+
end
|
55
74
|
end
|
56
75
|
|
57
76
|
def run!
|
58
|
-
|
59
|
-
|
77
|
+
commands = []
|
78
|
+
|
79
|
+
if bundle
|
80
|
+
commands << generate_code
|
60
81
|
remove_libs
|
61
|
-
|
62
|
-
|
63
|
-
|
82
|
+
commands << build(true)
|
83
|
+
commands << bundle_commands
|
84
|
+
run_commands(commands)
|
85
|
+
bundler_path = File.join(ENV['APP_ROOT'],'.bundle')
|
86
|
+
FileUtils.rm_rf(bundler_path)
|
64
87
|
else
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
88
|
+
if command == 'messages'
|
89
|
+
commands << generate_code
|
90
|
+
commands << build(false)
|
91
|
+
run_commands(commands)
|
92
|
+
elsif command == 'clean'
|
93
|
+
commands << generate_code
|
94
|
+
remove_libs
|
95
|
+
commands << build(true)
|
96
|
+
run_commands(commands)
|
97
|
+
else
|
98
|
+
commands << generate_code
|
99
|
+
commands << build(false)
|
100
|
+
run_commands(commands)
|
101
|
+
end
|
69
102
|
end
|
70
103
|
end
|
71
104
|
|
@@ -0,0 +1,95 @@
|
|
1
|
+
|
2
|
+
require 'digest'
|
3
|
+
require 'openssl'
|
4
|
+
require 'faraday'
|
5
|
+
require 'yaml'
|
6
|
+
require 'json'
|
7
|
+
require 'fileutils'
|
8
|
+
require_relative '../ruby_extensions/string'
|
9
|
+
|
10
|
+
module Kernel
|
11
|
+
def suppress_warnings
|
12
|
+
original_verbosity = $VERBOSE
|
13
|
+
$VERBOSE = nil
|
14
|
+
result = yield
|
15
|
+
$VERBOSE = original_verbosity
|
16
|
+
return result
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
suppress_warnings {OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE}
|
21
|
+
|
22
|
+
module GameMachine
|
23
|
+
module Console
|
24
|
+
class Bundle
|
25
|
+
|
26
|
+
attr_reader :command, :name, :bundle_dir, :bundle_file
|
27
|
+
def initialize(argv)
|
28
|
+
@command = argv.shift
|
29
|
+
@name = argv.shift
|
30
|
+
@bundle_dir = File.join(ENV['APP_ROOT'],'.game_machine')
|
31
|
+
@bundle_file = File.join(bundle_dir,'bundle.zip')
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def upload_bundle(name)
|
36
|
+
username = AppConfig.instance.config.gamecloud.user
|
37
|
+
api_key = AppConfig.instance.config.gamecloud.api_key
|
38
|
+
host = AppConfig.instance.config.gamecloud.host
|
39
|
+
|
40
|
+
url = "http://#{host}/bundle/#{username}/upload"
|
41
|
+
token = Digest::SHA256.hexdigest("#{username}#{name}#{api_key}")
|
42
|
+
file = Faraday::UploadIO.new(bundle_file, 'application/octet-stream')
|
43
|
+
body = { :file => file, :name => name }
|
44
|
+
|
45
|
+
|
46
|
+
response = conn.post do |req|
|
47
|
+
req.options[:timeout] = 10
|
48
|
+
req.options[:open_timeout] = 2
|
49
|
+
req.url url
|
50
|
+
req.headers['X-Auth'] = token
|
51
|
+
req.body = body
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def conn
|
57
|
+
Faraday.new do |f|
|
58
|
+
f.request :multipart
|
59
|
+
f.request :url_encoded
|
60
|
+
#f.response :logger
|
61
|
+
f.adapter Faraday.default_adapter
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def create_bundle
|
66
|
+
FileUtils.mkdir_p(bundle_dir)
|
67
|
+
FileUtils.rm_f(bundle_file)
|
68
|
+
system("cd #{ENV['APP_ROOT']} && bundle install --path=.game_machine/vendor/bundle >> /dev/null && rm -rf #{ENV['APP_ROOT']}/.bundle")
|
69
|
+
system("cd #{ENV['APP_ROOT']} && zip -r .game_machine/bundle.zip games config db lib java bin script web .game_machine/vendor mono >> /dev/null")
|
70
|
+
end
|
71
|
+
|
72
|
+
def run!
|
73
|
+
if name.nil? || name.blank?
|
74
|
+
puts "Must specify bundle name"
|
75
|
+
puts "Usage: game_machine service push [bundle name]"
|
76
|
+
exit
|
77
|
+
end
|
78
|
+
|
79
|
+
puts "Creating bundle"
|
80
|
+
create_bundle
|
81
|
+
|
82
|
+
puts "Uploading bundle to server"
|
83
|
+
response = upload_bundle(name)
|
84
|
+
|
85
|
+
if response.status == 204
|
86
|
+
puts "Push Successful"
|
87
|
+
else
|
88
|
+
puts response.body
|
89
|
+
puts "Push failed, server returned #{response.status}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module GameMachine
|
2
|
+
module Console
|
3
|
+
class Deploy
|
4
|
+
|
5
|
+
attr_reader :options, :service
|
6
|
+
def initialize(service,argv)
|
7
|
+
@options = parse_arguments(argv)
|
8
|
+
@service = service
|
9
|
+
end
|
10
|
+
|
11
|
+
def parse_arguments(arguments)
|
12
|
+
options = {}
|
13
|
+
|
14
|
+
OptionParser.new do |opt|
|
15
|
+
opt.banner = "Usage: game_machine deploy [options]"
|
16
|
+
opt.on('-n', '--name=name', String, 'Give a name to the bundle') { |v| options[:server] = v.strip }
|
17
|
+
|
18
|
+
opt.parse!(arguments)
|
19
|
+
end
|
20
|
+
|
21
|
+
unless options.has_key?(:name)
|
22
|
+
options[:name] = 'default'
|
23
|
+
end
|
24
|
+
|
25
|
+
options
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -2,13 +2,12 @@ module GameMachine
|
|
2
2
|
module Console
|
3
3
|
class Install
|
4
4
|
|
5
|
-
attr_reader :install_path, :help, :install_source_path
|
6
|
-
def initialize(argv,install_source_path)
|
7
|
-
@
|
5
|
+
attr_reader :install_path, :help, :install_source_path, :command
|
6
|
+
def initialize(command,argv,install_source_path)
|
7
|
+
@command = command
|
8
8
|
@install_path = argv.shift
|
9
|
-
|
10
|
-
|
11
|
-
end
|
9
|
+
@install_source_path = install_source_path
|
10
|
+
|
12
11
|
puts "Installing from #{install_source_path}"
|
13
12
|
end
|
14
13
|
|
@@ -16,39 +15,24 @@ module GameMachine
|
|
16
15
|
puts "Invalid install path #{install_path} (#{reason})"
|
17
16
|
end
|
18
17
|
|
19
|
-
def valid_input?
|
20
|
-
end
|
21
|
-
|
22
18
|
def run!
|
23
|
-
if help
|
24
|
-
show_help
|
25
|
-
return
|
26
|
-
end
|
27
|
-
|
28
19
|
if install_path.nil? || install_path.empty?
|
29
20
|
error("Invalid input")
|
30
21
|
return
|
31
22
|
end
|
32
23
|
|
33
|
-
if File.exists?(install_path)
|
24
|
+
if command == 'install' && File.exists?(install_path)
|
34
25
|
error("Directory exists")
|
35
26
|
return
|
36
27
|
end
|
37
28
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
def show_help
|
43
|
-
puts "new [install directory]"
|
44
|
-
end
|
45
|
-
|
46
|
-
def valid_install_path?
|
47
|
-
if File.exists?(install_path)
|
48
|
-
false
|
49
|
-
else
|
50
|
-
true
|
29
|
+
if command == 'upgrade' && !File.exists?(install_path)
|
30
|
+
error("Installation not found")
|
31
|
+
return
|
51
32
|
end
|
33
|
+
|
34
|
+
@install_path = File.expand_path(install_path)
|
35
|
+
send(command.to_sym)
|
52
36
|
end
|
53
37
|
|
54
38
|
def install
|
@@ -58,21 +42,67 @@ module GameMachine
|
|
58
42
|
FileUtils.cp_r(config_source,path)
|
59
43
|
FileUtils.cp_r(games_source,path)
|
60
44
|
FileUtils.cp_r(java_source,path)
|
61
|
-
FileUtils.cp_r(script_source,path)
|
62
45
|
FileUtils.cp_r(mono_source,path)
|
63
|
-
|
46
|
+
|
47
|
+
FileUtils.cp_r(web_source,path)
|
48
|
+
FileUtils.cp_r(lib_source,path)
|
49
|
+
FileUtils.cp_r(bin_source,path)
|
50
|
+
|
51
|
+
FileUtils.cp(gemfile_source,path)
|
52
|
+
FileUtils.cp(gemlockfile_source,path)
|
53
|
+
end
|
54
|
+
|
55
|
+
def upgrade
|
56
|
+
puts "Upgrading installation at #{install_path}"
|
57
|
+
path = File.expand_path(install_path)
|
58
|
+
|
59
|
+
puts "Upgrading mono"
|
60
|
+
FileUtils.rm_rf(File.join(path,'mono'))
|
61
|
+
FileUtils.cp_r(mono_source,path)
|
62
|
+
|
63
|
+
puts 'Upgrading java'
|
64
|
+
FileUtils.rm_rf(File.join(path,'java','project'))
|
65
|
+
FileUtils.cp_r(java_project_source, File.join(path,'java','project'))
|
66
|
+
|
67
|
+
puts 'Upgrading Gemfile'
|
68
|
+
FileUtils.rm_rf(File.join(path,'Gemfile'))
|
69
|
+
FileUtils.cp(gemfile_source,path)
|
70
|
+
|
71
|
+
FileUtils.rm_rf(File.join(path,'Gemfile.lock'))
|
72
|
+
FileUtils.cp(gemlockfile_source,path)
|
73
|
+
|
74
|
+
puts 'Upgrading lib'
|
75
|
+
FileUtils.rm_rf(File.join(path,'lib'))
|
76
|
+
FileUtils.cp_r(lib_source,path)
|
77
|
+
|
78
|
+
puts 'Upgrading bin'
|
79
|
+
FileUtils.rm_rf(File.join(path,'bin'))
|
80
|
+
FileUtils.cp_r(bin_source,path)
|
81
|
+
|
64
82
|
end
|
65
83
|
|
66
|
-
def
|
67
|
-
File.join(install_source_path,'
|
84
|
+
def gemfile_source
|
85
|
+
File.join(install_source_path,'Gemfile')
|
68
86
|
end
|
69
87
|
|
70
|
-
def
|
71
|
-
File.join(install_source_path,'
|
88
|
+
def gemlockfile_source
|
89
|
+
File.join(install_source_path,'Gemfile.lock')
|
72
90
|
end
|
73
91
|
|
74
|
-
def
|
75
|
-
File.join(install_source_path,'
|
92
|
+
def web_source
|
93
|
+
File.join(install_source_path,'web')
|
94
|
+
end
|
95
|
+
|
96
|
+
def lib_source
|
97
|
+
File.join(install_source_path,'lib')
|
98
|
+
end
|
99
|
+
|
100
|
+
def bin_source
|
101
|
+
File.join(install_source_path,'bin')
|
102
|
+
end
|
103
|
+
|
104
|
+
def mono_source
|
105
|
+
File.join(install_source_path,'mono')
|
76
106
|
end
|
77
107
|
|
78
108
|
def config_source
|
@@ -83,6 +113,10 @@ module GameMachine
|
|
83
113
|
File.join(install_source_path,'games')
|
84
114
|
end
|
85
115
|
|
116
|
+
def java_project_source
|
117
|
+
File.join(install_source_path,'java','project')
|
118
|
+
end
|
119
|
+
|
86
120
|
def java_source
|
87
121
|
File.join(install_source_path,'java')
|
88
122
|
end
|