Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

template nginx configuration with liquid #449

Merged
merged 3 commits into from
Nov 6, 2017
Merged

template nginx configuration with liquid #449

merged 3 commits into from
Nov 6, 2017

Conversation

mikz
Copy link
Contributor

@mikz mikz commented Oct 10, 2017

Replace bash script with a proper Lua CLI and template the nginx configuration by liquid.

This wouldn't be possible without awesome liquid interpreter https://github.com/chenxianyu2015/liquid-lua. Thanks.

Before bin/apicast -h

Usage bin/apicast
  -h Show this help
  -c <file> Path to custom config file (JSON).
  -d Daemonize
  -v Increase verbosity (can be repeated)
  -i Cache configuration for N seconds. Using 0 will reload on every request (not for production).
  -w <workers> Number of worker processes to start.
  -m <on|off> Whether to start worker processes. Only for development.
  -s <signal> Send signal to a master process: stop, quit, reopen, reload
  -p <pid> Path to the PID file.
  -b Load configuration on boot.
  -e Deployment environment. Can be staging or production.

After bin/apicast -h

Usage: apicast-cli start [OPTIONS]

Start APIcast

Options:
   --template <template> Nginx config template. (default: conf/nginx.conf.liquid)
   -e <environment>, --environment <environment>
                         Deployment to start.
   --dev                 Start in development environment
   -t, --test            Test the nginx config
   --debug               Debug mode. Prints more information.
   -c <configuration>, --configuration <configuration>
                         Path to custom config file (JSON)
   -d, --daemon          Daemonize.
   -w <workers>, --workers <workers>
                         Number of worker processes to start.
   -p <pid>, --pid <pid> Path to the PID file.
   -b, --boot            Load configuration on boot.
   -l, --lazy            Load configuration on demand.
   -i <refresh_interval>, --refresh-interval <refresh_interval>
                         Cache configuration for N seconds. Using 0 will reload on every request (not for production).
   -v, --verbose         Increase logging verbosity (can be repeated).
   -q, --quiet           Decrease logging verbosity.
   --log-level <log_level>
                         Set log level (default: warn)
   --log-file <log_file> Set log file (default: stderr)
   -h, --help            Show this help message and exit.

      Example: apicast start --dev
        This will start APIcast in development mode.

busted 2.0.rc12-1
dkjson 2.5-2
inspect 3.1.0-1
ldoc 1.4.6-2
liquid scm-1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to work around this before luarocks/luarocks#739 is fixed. Probably by doing the whole clone and copy in rover.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikz mikz force-pushed the templating branch 3 times, most recently from 8c7ed2b to a62e0ee Compare November 2, 2017 08:44
@mikz mikz changed the title [WIP] templating nginx configuration prototype template nginx configuration with liquid Nov 2, 2017
@mikz mikz requested a review from davidor November 2, 2017 08:47
lua-resty-http 0.11-0|
lua-resty-iputils 0.3.0-1|
lua-resty-jwt 0.1.11-0|
lua-resty-repl 0.0.6-0|3878f41b7e8f97b1c96919db19dbee9496569dda
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the hash in this one? It has a version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but version can still point to a scm to get the source. Depends if it is a rock or a rockspec.

rock has a source packaged in the bundle but rockspec has to download it from somewhere
in this case repl has only rockspec and that points to a git tag https://luarocks.org/modules/saksmlz/lua-resty-repl/0.0.6-0

@3scale 3scale deleted a comment from octobot Nov 3, 2017
@@ -0,0 +1,92 @@
env REDIS_HOST;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is apicast/conf/nginx.conf still needed?

Copy link
Contributor

@davidor davidor Nov 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a couple of settings present in the original config but not on this template:

  lua_max_running_timers 2048;
  lua_socket_pool_size 512;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha! they probably lost during the rebase, good catch!

the plain nginx.conf should not be needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed both (removed the old file and added those missing directives).

mikz added 2 commits November 6, 2017 09:59
* we need to use some templating to customize nginx directives not
  accessible from Lua code (like buffer sizes, etc.)

* using liquid templating language

* introduce `bin/cli` that is a main entrypoint to:
    - configure paths to load local code and dependencies
    - execute lua cli code

* `bin/apicast` is now slim perl wrapper to setup paths,
  because it has access to current working folder and
  ritch stdlib for working with filesystem and env variables

* introduce concept of an environment,
  so each can have own config, like rails

* use latest rover and lock scm dependencies
  3scale/lua-rover#2

update changelog
Copy link
Contributor

@davidor davidor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants