kuon

kuon

I use edeliver for deployment and it works great.

I’d like to be able to extend edeliver to run custom commands, for example:

mix edeliver console

would do something like this:

$ ssh deploy-host
# /approot/bin/myapp remote_console

In ruby apps, I can juste write a capistrano script, I wonder how to approach this with my elixir apps.

Showing Posts 1 to 5

bharendt

bharendt

Edeliver Core Team

Yes, this is possible. If you create a bash script at .deliver/strategies/erlang-console containing a run() function and an optional help() function you should be able to run edeliver console. If you want to pass custom parameters, you can add a .deliver/help script file implementing an accepts_custom_command_argument() function to which the command is passed as first and the argument as second parameter and which should return 0 for accepted arguments, otherwise 1. The output of the optional print_custom_commands_help() function will be appended to the edeliver help output.

kuon

kuon OP

Great insight, thanks.

kuon

kuon OP

I was able to create the command, but how can I run the command on my staging or production host? I tried __sync_remote but it runs the command on my build host.

bharendt

bharendt

Edeliver Core Team

True, __sync_remote() executes commands on the build host. __remote() executes commands on the deploy hosts, but asynchronously. This will not work nor make sense for a remote console. Starting a remote console will work for one node only in any case, so you must ensure that there is only one deploy host in you config or that you set the deploy host config to a single host according to your console command line arguments. Maybe having a look at the __execute_node_command_synchronously() function might help. You could also source that file and call that function or __execute_node_command() directly. A custom .deliver/strategies/erlang-console script could look like that:

#!/usr/bin/env bash

REQUIRED_CONFIGS+=("APP")

# contains __execute_node_command
source "$(dirname $(dirname ${BASH_SOURCE[0]}))/strategies/erlang-node-execute"
# contains require_node_config
source "$(dirname $(dirname ${BASH_SOURCE[0]}))/libexec/erlang"

# sets the deploy hosts from the config (PRODUCTION_HOSTS or STAGING_HOSTS) 
# there must be only one host configured to be able to use a remote console
require_node_config

run() {
  # ssh setup  
  authorize_hosts   
  # again make sure that only one node is used (first one)
  local _node=${NODES# *}
  # run command on deploy host / node
  __execute_node_command "single_node" "$_node" "remote_console"
}
kuon

kuon OP

I came up with the following:

#!/usr/bin/env bash

REQUIRED_CONFIGS+=("APP")
REQUIRED_CONFIGS+=("NODE_ENVIRONMENT")
REQUIRED_CONFIGS+=("NODE_ACTION")

NODE_ACTION="remote_console"
NODE_ENVIRONMENT=$DEPLOY_ENVIRONMENT || "staging"
: ${NODE_ENVIRONMENT:="staging"}


source ${BASE_PATH}/strategies/erlang-node-execute

run() {
  # ssh setup
  authorize_hosts

  local _node_command=$NODE_ACTION

  # take the first node only
  local _nodes=(${NODES// / })
  local _node=${_nodes[0]}
  __execute_node_command "single_node" "$_node" "$_node_command"
}

Which works, except for one details, the erlang nodename is modified, and I end up in
iex(remsh3379d012-kura@127.0.0.1)1> instead of iex(kura@127.0.0.1)1>.

I was able to trace the problem to the absence of TTY. If my app is called without a TTY, erlang seems to randomize the node name.

I can just replace __execute_node_command with a direct ssh call now that I am more familiar with the edeliver internals. But I wonder if maybe this is a bug somehow, because I noticed that ssh was called with -t from __execute_node_command.

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
water
I’m aware of 2 such projects, are there others? git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
itzmidinesh
Hi all, I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
peck
Hi everyone. My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
leoschweizer
Hi, we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
csmr
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley: Mutonex gamedesign was finish...
New
Stef-Verniers
Hello I’ve been coding in Elixir for almost two years now because of my current job where we implemented Elixir in our application. But ...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews