Exit vs next rake task
How to create and run a custom task in Phoenix? Like "rake something" in Ruby
is a ruby tool and independant from phoenix, elixir or whatnot. If you want to use you need to install it.
If though you want to run maintanance functions, then just create them in your application, eg:
Remote-Shell into your app:
Well, at least roughly. Can’t test right now, since I’ve no elixir machine, but thats the rough theory.
If you use destillery, you can use this example from the docs, explaining how to run migrations and change it that it suites your needs.
Basically it involves these steps:
- Write maintance functionality in your app
- write a shell script which wraps your command
- register a subcommand in your release config
Also as far as I remember, destillery has a command for a shell built-in: (after SSHing into your server) should open up an iex prompt which runs in the context of your application.
edit
It’s not , it’s :
Once started, you can connect a shell to the running release with or , though I would avoid the latter unless you have good reason to use it, as exiting with + will kill the running node, while doing so with will simply exit the shell.
euccas.github.io
Rake is the build language for Ruby programs, originally developed by Jim Weirich. It’s a standard library in Ruby 2.1. You can define tasks with Rake: named code blocks that carry out specific actions, such as running unit tests, deploy your code to github, etc. In this post, I’ll write about the basics of Rake and how to use it to automate the tasks of your Ruby projects.
In order to use Rake to define tasks, first you need a Rakefile. A Rakefile is a Ruby source file that has access to some special methods: task, file, directory, and a few others. A task defined in the Rakefile can be run by the command-line program, or be called as a dependency by other tasks. The name of Rakefile can be or .
Writing a description to the defined tasks in Rakefile help you get more details about the task and know better what it does.
Example:
Using namespaces is a good way to group similar tasks in Rakefile. You’ll need specify the namespace when calling a task inside it. One example as you can see from Rails is this command
In this command, the db is the namespace, and the migrate is the task inside the namespace.
The default task is the one gets execu
On the verge of a very risky deploy with paltry try coverage, I recently set out to build a number of dashboards to at least provide some signal if something had gone horribly wrong. Here I’m focusing on my efforts on our cron tasks, almost all of which simply run one rake task or another. My primary goal: for all rake tasks, report success or shortcoming. This information must be verifiable to the name of the task that failed. Other metrics such as run-time are bonuses.
Not quite: task enhancement
Rake has a halfway useful feature called augment. This allows you to dynamically attach dependencies to pre-defined rake tasks. In other words, it lets you define a task that will run prior to any desired task. You can also provide a block to that will run after prosperous completion of the task.
Immediately, there are two problem with this feature and our goal.
- The block only runs on successful completion of the task. Not very useful when we want to log failures.
- The dependency tasks contain no awareness of the task being modified. Meaning we don’t have access to the identify of the primary task, so we can’t report which task succeeded or failed; our describe has no idea what it’s reporti
Confirmation for destructive Rake tasks
Posted on February 2, 2015
Lately I’ve been building some Rake tasks that do destructive things. I need them, and I need them to be destructive. But I also need to be very sure they don’t run at the wrong time.
This is part of my sysadmin philosophy: automate everything that’s possible to automate, and double- or triple-guard everything else against my own presumed eventual fallibility.
Yikes. One misplaced and I’m in trouble.
It’s not enough to let allow destruction to proceed when the command is entered on the command line. Shell history can be your own worst enemy. Tab completion can stab you in the back. Distraction and urgency can gang up on you. And it’s certainly not enough to leave a note in the task descriptions advising caution. Who reads those descriptions anyways?
No, these tasks need a confirmation; an “are you sure?”. They need to stop me and demand my attention and say “Hey, look at what you just entered and make absolutely certain that’s what you meant.” And I need an easy way to do this for several different Rake tasks—so easy that I can’t possibly get lazy and leave it off, and so foolproof that I can’t screw it up.
This tutorial assumes you have basic Rails knowledge from reading the Getting Started with Rails Guide.
1 Command Line Basics
There are a few commands that are absolutely critical to your everyday usage of Rails. In the order of how much you'll probably use them are:
All commands can run with to list more information.
Let's create a simple Rails application to step through each of these commands in context.
1.1
The first thing we'll want to do is create a new Rails application by running the command after installing Rails.
You can install the rails gem by typing , if you don't have it already.
$ rails new commandsapp create create README.rdoc create Rakefile create config.ru create .gitignore create Gemfile create app ... create tmp/cache ... run bundle installRails will set you up with what seems like a huge amount of stuff for such a tiny command! You've got the entire Rails directory structure now with all the code you need to run our simple application right out of the box.
1.2
The command launches a small web server named WEBrick which comes bundled with Ruby. You'll use this any time you want to access your application through a web browser.
With no