gloo-web 1.6 → 1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/objs/svr.rb +27 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76804bbf747238b84d964890005f32e2a6d801b3926169120da712ff542d52b1
4
- data.tar.gz: 907cac263a2583f2c8fa6d1a9b59a5aa2f4542c4e5bad0a7f9a025fb2c153029
3
+ metadata.gz: f6d3032841d8b93dd380ad4d6663d49ecd09e643e9367e4bd692b77bc553bf15
4
+ data.tar.gz: b93f0d2eb10d68f534efafc93e9309fcb17082a8c32225f2e84a7132d4ce19a3
5
5
  SHA512:
6
- metadata.gz: ef2ae150df15c224c1106a5ef35a0f5ad38b498f5791f36add563a90655b2428ca0ba5ee4710938821287a887a2baa663fed53a84e53aaa8a8085c179d489930
7
- data.tar.gz: d5e7582e24bf8b1a0418dbe9c9c20cf02a73acebbf61bd70215f971a0353faf8bf53a2017f368f125f2df19b768b4231ff4cc8e572c0b0cc96ca5f17b3e0878a
6
+ metadata.gz: 93c67f1b0883db8f204d2cc623a7393fbc58f328ca946446348727434be72171916b8dbbbd48b781e730c05689e6a929c52f93565908134baf37f5d99ace773d
7
+ data.tar.gz: db469e4e91276218949244391269bd9b9c390f6c0b0c6ea524932796a45250182f3f4e7207c9646a9ab1e1296e4f8968fd0bc28e26612dc4fc9d9e56593a8260
data/lib/objs/svr.rb CHANGED
@@ -69,6 +69,8 @@ module Objs
69
69
 
70
70
  # Messages
71
71
  SERVER_NOT_RUNNING = 'The web server is not running!'.freeze
72
+ NOT_IN_SCRIPT_MODE_ERR = "Could not start the web server: an app runs in App mode. Run it with 'gloo --app %s'.".freeze
73
+ UNKNOWN_APP_FOLDER = '<folder>'.freeze
72
74
  SERVER_ALREADY_RUNNING = 'The web server is already running!'.freeze
73
75
 
74
76
  #
@@ -418,6 +420,8 @@ module Objs
418
420
  # Start the gloo web server.
419
421
  #
420
422
  def msg_start
423
+ return script_mode_err if @engine.mode == Gloo::App::Mode::SCRIPT
424
+
421
425
  if @engine.app_running?
422
426
  @engine.err SERVER_ALREADY_RUNNING
423
427
  return
@@ -431,6 +435,26 @@ module Objs
431
435
  # The running app will call the start function (below)
432
436
  end
433
437
 
438
+ #
439
+ # A web server is an app, and an app runs in App mode. Started from
440
+ # a script run (gloo folder/start.gloo) it would stop as soon as the
441
+ # script finished: report the mistake, with the command that runs
442
+ # the app, instead of starting.
443
+ #
444
+ def script_mode_err
445
+ @engine.err format( NOT_IN_SCRIPT_MODE_ERR, app_folder )
446
+ end
447
+
448
+ #
449
+ # The folder of the file gloo was run with (in Script mode, the
450
+ # first file loaded): the folder to give --app. A placeholder if
451
+ # nothing came from a file.
452
+ #
453
+ def app_folder
454
+ pn = @engine.persist_man.maps.first&.pn
455
+ return pn ? File.dirname( pn ) : UNKNOWN_APP_FOLDER
456
+ end
457
+
434
458
  #
435
459
  # Stop the running web server.
436
460
  #
@@ -769,7 +793,9 @@ module Objs
769
793
  'response_data (container) — Optional. Data available for use in on_response (request_data is also available at this point): page, type, code, elapsed, db (all string, all optional, populated only if present).'
770
794
  ],
771
795
  :messages => [
772
- 'start — Start the web server. It is an error if a web server is already running. If it can\'t listen on its port (in use, or needs root privileges), that is reported as an error and the server stops.',
796
+ 'start — Start the web server. It is an error if a web server is already running. If it can\'t listen on its port (in use, or needs root privileges), that is reported as an error and the server stops. ' \
797
+ 'A web server is an app and runs in App mode (gloo --app {folder}): started from a script run (gloo {folder}/start.gloo) it does not start, and reports ' \
798
+ "Could not start the web server: an app runs in App mode. Run it with 'gloo --app {folder}'.",
773
799
  'stop — Stop the web server. It is an error if it is not running.',
774
800
  'list_routes — Show the routing table. A debugging tool.',
775
801
  'list_assets — Show the list of assets. A debugging tool.',
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gloo-web
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.6'
4
+ version: '1.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Crane