Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 02:10
    Blacksmoke16 review_requested #374
  • 02:10
    Blacksmoke16 review_requested #374
  • 01:56
    Blacksmoke16 labeled #372
  • 01:56
    Blacksmoke16 labeled #372
  • 01:56
    Blacksmoke16 commented #372
  • 01:54
    Blacksmoke16 labeled #374
  • 01:54
    Blacksmoke16 labeled #374
  • 01:54
    Blacksmoke16 opened #374
  • Dec 06 22:09
    Blacksmoke16 assigned #373
  • Dec 06 22:09
    Blacksmoke16 labeled #373
  • Dec 06 22:09
    Blacksmoke16 labeled #373
  • Dec 06 22:09
    Blacksmoke16 commented #373
  • Dec 06 21:15
    msa7 opened #373
  • Dec 05 08:56
    X-tymchenko edited #1167
  • Dec 05 08:55
    X-tymchenko opened #1167
  • Dec 02 19:52
    wontruefree commented #1163
  • Dec 02 07:44
    g33kidd commented #1163
  • Nov 29 20:45
    msa7 opened #372
  • Nov 28 15:32
  • Nov 22 05:49
Nathaniel Suchy
@nsuchy
this is really weird behavior
Blacksmoke16
@Blacksmoke16
it probably installs them in the container then the copy after overrides it
is what i would vote?
Nathaniel Suchy
@nsuchy
got everything working now
:D
Blacksmoke16
@Blacksmoke16
:thumbsup:
Nathaniel Suchy
@nsuchy
@robacarp Can you take a look at robacarp/mosquito#39
My app has several Redis containers for different systems and this would simplify setting a Redis container for Mosquito
Damian Hamill
@damianham
@nsuchy I run my amber apps in docker containers and rather than use COPY . /app I mount the project folder as a volume on /app (with docker-compose) then file saves are detected and the app rebuilds. My startup script runs shards update; shards build amber; bin/amber watch. Here are my Dockerfile and docker-compose.yml files
FROM crystallang/crystal:0.31.1

# Install Dependencies
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq && apt-get install -y --no-install-recommends libpq-dev libsqlite3-dev libmysqlclient-dev libreadline-dev git curl vim netcat
RUN apt-get install -y build-essential software-properties-common libavahi-client-dev libavahi-compat-libdnssd1 libavahi-compat-libdnssd-dev

# Install Node
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs nano sqlite3

# Install Amber
ENV PATH /app/bin:$PATH
WORKDIR /app

# Add Project deps
COPY package.json shard.yml /app/

RUN shards update

RUN shards build amber

ADD . /app

# docker-compose.yml
version: '2'

services:
  smartbox:
    build: .
    command: bash /app/scripts/startup.sh
    depends_on:
      - nodered
      - signalk
    environment:
      DATABASE_URL: sqlite3:./db/smartbox_development.db
    ports:
      - 3500:80
    volumes:
      - .:/app
robacarp
@robacarp

@nsuchy another way to do this is to wrap each service in a shell script which alters the environment (export REDIS_URL=“$MOSQUITO_REDIS”) and then execs into the process you’re running (exec shards run mosquito).

The problem with declaring an environment variable dedicated to this setup style, is it doesn’t scale well. Every bespoke pattern requires all supporting libraries to update accordingly — N code changes for N usage patterns.

Nathaniel Suchy
@nsuchy
@robacarp Even if I give one container a different REDIS_URL I'm still using a different REDIS_URL variable for my data cache Redis instance.
There's one for caching, one for background jobs.
Nathaniel Suchy
@nsuchy
@robacarp Just gonna say your background task library Mosquito gave my app an enormous speed boost. Previously we were running a lot of slow API calls in the background (Proxmox API is slow even with caching), putting them in the background is great
robacarp
@robacarp
Glad to hear it
@nsuchy this is what I was looking to use to setup a redis url config parameter: https://github.com/luckyframework/habitat
Nathaniel Suchy
@nsuchy
@robacarp You want me to add that as a dependency and use it for the REDIS URL?
robacarp
@robacarp
if you'd like... it's been on my radar for months and I haven't taken the time
I'd much prefer that over another env var
Nathaniel Suchy
@nsuchy
where exactly should I be placing the initilizer code?
Is the base class the correct place
robacarp
@robacarp
sure
Nathaniel Suchy
@nsuchy
@robacarp how do I modify the unit test, it creates an exception unless a Redis url is specified now
robacarp
@robacarp
It can be removed in think
Blacksmoke16
@Blacksmoke16
any reason to bump the minor version?
this should be BC no?
Nathaniel Suchy
@nsuchy
@Blacksmoke16 It's a breaking change
It reads settings in a new way and will ignore the redis url env
Blacksmoke16
@Blacksmoke16
fair enough
sclee15
@sclee15
Can I do a update where query with Granite?
Blacksmoke16
@Blacksmoke16
Could just do a one off exec call
Probably would be the way to go, what's the use case?
sclee15
@sclee15
@Blacksmoke16 thank you.
Igor Alexandrov
@igor-alexandrov
Hi guys, how to setup Amber to log to file instead of STDOUT in production?
Igor Alexandrov
@igor-alexandrov
Another question is how to add http basic auth?
Dru Jensen
@drujensen
Hi Igor. The logger can be configured with a different IO. https://crystal-lang.org/api/0.31.1/Logger.html
in the config/settings.cr you can uncomment settings.logger = Amber::Environment::Logger.new(File.open("blog.log", "w”))
Dru Jensen
@drujensen
for BasicAuth you can add a pipe:
```

class BasicAuth
include HTTP::Handler
BASIC = "Basic"
AUTH = "Authorization"
AUTH_MESSAGE = "Could not verify your access level for that URL.\nYou have to login with proper credentials"
HEADER_LOGIN_REQUIRED = "Basic realm=\"Login Required\""

property username : String
property password : String

def initialize(@username, @password)
end

def call(context)
  if context.request.headers[AUTH]?
    if value = context.request.headers[AUTH]
      if value.size > 0 && value.starts_with?(BASIC)
        return call_next(context) if authorized?(value)
      end
    end
  end
  headers = HTTP::Headers.new
  context.response.status_code = 401
  context.response.headers["WWW-Authenticate"] = HEADER_LOGIN_REQUIRED
  context.response.print AUTH_MESSAGE
  ""
end

private def authorized?(value)
  username, password = Base64.decode_string(value[BASIC.size + 1..-1]).split(":")
  @username == username && @password == password
end

end

not sure why that didn’t properly format
Igor Alexandrov
@igor-alexandrov
@drujensen thanks!
sclee15
@sclee15
For an amber channel, where is the right place to store channel state?
Blacksmoke16
@Blacksmoke16
@sclee15 amber channel?
sclee15
@sclee15
I mean websocket channel
Jack
@wontruefree
I imagine there is a large crossover with #crystal-lang. But I just wanted to do a quick plug for Chicago Crystal. Ary the creator of Crystal will be speaking. chicagocrystal.org/events/bbhsjryzqbhb/
Dru Jensen
@drujensen
Thanks @jack
Jack
@wontruefree
you are welcome
some info was just updated but I hope to see you all there
From IRC (bridge bot)
@FromIRC
<dev0ps> hello
Blacksmoke16
@Blacksmoke16
o/