rocketeer
rocketeer copied to clipboard
cant create task
Hi
To be consistent the docs. please update in this http://rocketeer.autopergamene.eu/#/docs/docs/II-Concepts/Tasks in the "Defining Tasks in the config file" section 'MyNamespace\MyTaskClass', ==> 'MyTasks\Migrate'
Also i tried to create a task, but i cannot.
this is the tasks/mytasks.php
<?php
namespace MyTasks;
class ConfRelease extends \Rocketeer\Abstracts\AbstractTask {
/**
* Description of the Task
*
* @var string
*/
protected $description = 'Deploys release CakePHP configuration';
/**
* Executes the Task
*
* @return void
*/
public function execute() {
$this->explainer->line('Deploying release CakePHP configuration');
$this->upload(base_path().'/configs/database_zoli.php', $this->releasesManager->getCurrentReleasePath().'/app/Config/database.php');
$this->upload(base_path().'/configs/core_release.php', $this->releasesManager->getCurrentReleasePath().'/app/Config/core.php');
$this->upload(base_path().'/configs/AppController_release.php', $this->releasesManager->getCurrentReleasePath().'/app/Controller/AppController.php');
$this->run('chmod 755 ' . $this->releasesManager->getCurrentReleasePath().'/app/Config/core.php');
$this->run('chmod 755 ' . $this->releasesManager->getCurrentReleasePath().'/app/Config/database.php');
$this->run('chmod 755 ' . $this->releasesManager->getCurrentReleasePath().'/app/Controller/AppController.php');
//$this->setPermissions($this->releasesManager->getCurrentReleasePath().'/app/Config/core.php');
//$this->setPermissions($this->releasesManager->getCurrentReleasePath().'/app/Config/database.php');
return;
}
}
?>
after running rocketeer, i got the following:
$ vendor/anahkiasen/rocketeer/bin/rocketeer
Rocketeer version 2.1.2
Current state
application x
configuration /home/bakro/Documents/aptana/x/.rocketeer
tasks /home/bakro/Documents/aptana/x/.rocketeer/tasks
events /home/bakro/Documents/aptana/x/.rocketeer/events
logs /home/bakro/Documents/aptana/x/.rocketeer/logs
Usage:
[options] command [arguments]
Options:
--help -h Display this help message
--quiet -q Do not output any message
--verbose -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--version -V Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
--no-interaction -n Do not ask any interactive question
--env The environment the command should run under.
Available commands:
check Check if the server is ready to receive the application
cleanup Clean up old releases from the server
closure Mytask\ConfDebug
current Display what the current release is
deploy Deploys the website
flush Flushes Rocketeer's cache of credentials
help Displays help for a command
ignite Creates Rocketeer's configuration
list Lists commands
rollback Rollback to the previous release, or to a specific one
setup Set up the remote server for deployment
strategies Lists the available options for each strategy
teardown Remove the remote applications and existing caches
test Run the tests on the server and displays the output
tinker Debug Rocketeer's environment
update Update the remote server without doing a new release
plugin
plugin:config Publishes the configuration of a plugin
plugin:install Install a plugin
plugin:list Lists the currently enabled plugins
What do you have in hooks.php
?
<?php
return [
// Tasks
//
// Here you can define in the `before` and `after` array, Tasks to execute
// before or after the core Rocketeer Tasks. You can either put a simple command,
// a closure which receives a $task object, or the name of a class extending
// the Rocketeer\Abstracts\AbstractTask class
//
// In the `custom` array you can list custom Tasks classes to be added
// to Rocketeer. Those will then be available in the command line
// with all the other tasks
//////////////////////////////////////////////////////////////////////
// Tasks to execute before the core Rocketeer Tasks
'before' => [
'setup' => [],
'deploy' => [],
'cleanup' => [],
],
// Tasks to execute after the core Rocketeer Tasks
'after' => [
'setup' => [],
'deploy' => [
],
'cleanup' => [],
],
// Custom Tasks to register with Rocketeer
'custom' => [
'MyTasks\ConfDebug',
'MyTasks\ConfRelease'
],
];
oh i had a typo, but why isnt showing the console the right name for conf:release:
$ vendor/anahkiasen/rocketeer/bin/rocketeer
Rocketeer version 2.1.2
Current state
application x
configuration /home/bakro/Documents/aptana/x/.rocketeer
tasks /home/bakro/Documents/aptana/x/.rocketeer/tasks
events /home/bakro/Documents/aptana/x/.rocketeer/events
logs /home/bakro/Documents/aptana/x/.rocketeer/logs
Usage:
[options] command [arguments]
Options:
--help -h Display this help message
--quiet -q Do not output any message
--verbose -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--version -V Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
--no-interaction -n Do not ask any interactive question
--env The environment the command should run under.
Available commands:
check Check if the server is ready to receive the application
cleanup Clean up old releases from the server
current Display what the current release is
deploy Deploys the website
flush Flushes Rocketeer's cache of credentials
help Displays help for a command
ignite Creates Rocketeer's configuration
list Lists commands
rollback Rollback to the previous release, or to a specific one
setup Set up the remote server for deployment
strategies Lists the available options for each strategy
teardown Remove the remote applications and existing caches
test Run the tests on the server and displays the output
tinker Debug Rocketeer's environment
update Update the remote server without doing a new release
1 Deploys release CakePHP configuration
conf
conf:debug Deploys debug CakePHP configuration
plugin
plugin:config Publishes the configuration of a plugin
plugin:install Install a plugin
plugin:list Lists the currently enabled plugins
what that "1" for that name?
Not sure, what does ConfRelease look like?
<?php
namespace MyTasks;
class ConfRelease extends \Rocketeer\Abstracts\AbstractTask {
/**
* Description of the Task
*
* @var string
*/
protected $description = 'Deploys release CakePHP configuration';
/**
* Executes the Task
*
* @return void
*/
public function execute() {
$this->explainer->line('Deploying release CakePHP configuration');
$this->upload(base_path().'/configs/database_zoli.php', $this->releasesManager->getCurrentReleasePath().'/app/Config/database.php');
$this->upload(base_path().'/configs/core_release.php', $this->releasesManager->getCurrentReleasePath().'/app/Config/core.php');
$this->upload(base_path().'/configs/AppController_release.php', $this->releasesManager->getCurrentReleasePath().'/app/Controller/AppController.php');
$this->run('chmod 755 ' . $this->releasesManager->getCurrentReleasePath().'/app/Config/core.php');
$this->run('chmod 755 ' . $this->releasesManager->getCurrentReleasePath().'/app/Config/database.php');
$this->run('chmod 755 ' . $this->releasesManager->getCurrentReleasePath().'/app/Controller/AppController.php');
//$this->setPermissions($this->releasesManager->getCurrentReleasePath().'/app/Config/core.php');
//$this->setPermissions($this->releasesManager->getCurrentReleasePath().'/app/Config/database.php');
return;
}
}
?>
Try doing this in the custom
array:
'conf:debug' => 'MyTasks\ConfDebug',
'conf:release' => 'MyTasks\ConfRelease',
See if you still get the 1?
that helps, but if i run rocketeer conf:debug i get the following:
$ vendor/anahkiasen/rocketeer/bin/rocketeer conf:debug
| Closure (conf-debug) [~1.76s]
$ cd /var/www/html/releases/20150313181116
$ conf-debug
[root@g] (do-dev) bash: conf-debug: command not found
Execution time: 1.7495s
Saved logs to /home/bakro/Documents/aptana/g/.rocketeer/logs/do-dev--20150313.log
it tries to run the conf:debug on the server
i merged the classes of the conf:debug and the conf:release:
<?php
namespace MyTasks;
class ConfRelease extends \Rocketeer\Abstracts\AbstractTask {
/**
* Description of the Task
*
* @var string
*/
protected $description = 'Deploys release CakePHP configuration';
/**
* Executes the Task
*
* @return void
*/
public function execute() {
$this->explainer->line('Deploying release CakePHP configuration');
$this->upload(base_path().'/configs/database_zoli.php', $this->releasesManager->getCurrentReleasePath().'/app/Config/database.php');
$this->upload(base_path().'/configs/core_release.php', $this->releasesManager->getCurrentReleasePath().'/app/Config/core.php');
$this->upload(base_path().'/configs/AppController_release.php', $this->releasesManager->getCurrentReleasePath().'/app/Controller/AppController.php');
$this->run('chmod 755 ' . $this->releasesManager->getCurrentReleasePath().'/app/Config/core.php');
$this->run('chmod 755 ' . $this->releasesManager->getCurrentReleasePath().'/app/Config/database.php');
$this->run('chmod 755 ' . $this->releasesManager->getCurrentReleasePath().'/app/Controller/AppController.php');
//$this->setPermissions($this->releasesManager->getCurrentReleasePath().'/app/Config/core.php');
//$this->setPermissions($this->releasesManager->getCurrentReleasePath().'/app/Config/database.php');
return;
}
}
class ConfDebug extends \Rocketeer\Abstracts\AbstractTask {
/**
* Description of the Task
*
* @var string
*/
protected $description = 'Deploys debug CakePHP configuration';
/**
* Executes the Task
*
* @return void
*/
public function execute() {
$this->explainer->line('Deploying debug CakePHP configuration');
$this->upload(base_path().'/configs/database_zoli.php', $this->releasesManager->getCurrentReleasePath().'/app/Config/database.php');
$this->upload(base_path().'/configs/core_debug.php', $this->releasesManager->getCurrentReleasePath().'/app/Config/core.php');
$this->upload(base_path().'/configs/AppController_debug.php', $this->releasesManager->getCurrentReleasePath().'/app/Controller/AppController.php');
$this->run('chmod 755 ' . $this->releasesManager->getCurrentReleasePath().'/app/Config/core.php');
$this->run('chmod 755 ' . $this->releasesManager->getCurrentReleasePath().'/app/Config/database.php');
$this->run('chmod 755 ' . $this->releasesManager->getCurrentReleasePath().'/app/Controller/AppController.php');
//$this->setPermissions($this->releasesManager->getCurrentReleasePath().'/app/Config/core.php');
//$this->setPermissions($this->releasesManager->getCurrentReleasePath().'/app/Config/database.php');
return;
}
}
?>
Ok no it seems it's not finding your classes, you say they're in .rocketeer/tasks
, both?
yeah, i just merged them in one file (see my last comment) and the file's path is: .rocketeer/tasks/mytasks.php
I ran into the exact same problem.
Created a task folder with two php classes in it and added them to the 'custom' section of the hooks.php array. With one class it works without a problem, but when adding a second one, the second class is registered with '1' as task name.
I also tried specifying the keys in the custom array, as suggested, but than I also have the same problem as bakroistvan. The name of the task is run as a command on the server.
I was able to work around this problem by creating an events.php file and using the rocketeer facade to register the tasks.
In .rocketeer/events.php:
use Rocketeer\Facades\Rocketeer;
Rocketeer::add('MyTasks\TaskOne');
Rocketeer::add('MyTasks\TaskTwo');
bump
Having the same problem. And the problem seems to come from the name case.
When I name my class/filename with only one upper case letter it works:
hooks.php
'custom' => [
'newrelic' => 'tasks\Newrelic',
],
tasks/Newrelic.php:
<?php
namespace tasks;
use Rocketeer\Abstracts\AbstractTask;
class Newrelic extends AbstractTask
{
BUT when I user CamelCase for the class name "NewRelic" It start looking for a Clousure?
staging/0 | Closure (new-relic)
$ cd /var/www/asdf/releases/20150622093300
$ new-relic
Also the $name of the Task seems to play a part here.
If I do this it works:
namespace tasks;
use Rocketeer\Abstracts\AbstractTask;
class Newrelic extends AbstractTask
{
/**
* Name of the Task
*
* @var string
*/
protected $name = 'Newrelic';
Reediks-iMac:Winter Rocketeer reediktuuling$ rocketeer newrelic
staging/0 | Newrelic (Pushes deploy information to NewRelic)
But if I change the $name it start looking for a command line task ?
namespace tasks;
use Rocketeer\Abstracts\AbstractTask;
class Newrelic extends AbstractTask
{
/**
* Name of the Task
*
* @var string
*/
protected $name = 'Newrelic Task';
staging/0 | Closure (newrelic-task) [~1.3s]
$ cd /var/www/asdf/releases/20150622093300
$ newrelic-task
Apparently giving the task a singe uppercase name works:
'custom' => [
'newrelic' => 'tasks\NewRelicDeployment',
],
class NewRelicDeployment extends AbstractTask
{
/**
* Name of the Task
*
* @var string
*/
protected $name = 'Newrelic';
$ rocketeer newrelic
staging/0 | Newrelic (Pushes deploy information to NewRelic)
Rocketeer version 2.1.2 I have the same issue as @kevinbreed 's. My fix is in custom tasks array giving each custom task a key. e.g:
// Custom Tasks to register with Rocketeer
'custom' => [
'custom-task-one' => 'MyNameSpace\CustomTaskOne',
'custom-task-two' => 'MyNameSpace\CustomTaskTwo',
],
Then running rocketeer
the commands are listed as
custom
custom:task:one
custom:task:two
I'm experiencing the same problem.
I've created 2 tasks under ".rocketeer/tasks". One is the "Cachewarmup" task, which file is:
namespace PrietoTasks;
class Cachewarmup extends \Rocketeer\Abstracts\AbstractTask
{
/**
* Description of the Task
*
* @var string
*/
protected $description = 'Warms up the cache';
/**
* Executes the Task
*
* @return void
*/
public function execute()
{
$this->explainer->line('Warming up cache');
return $this->runForCurrentRelease('php app/console cache:warmup');
}
}
Notice the command itself.
My ".rocketeer/hooks.php" custom tasks are:
// Custom Tasks to register with Rocketeer
'custom' => [
'app-warmup' => 'PrietoTasks\Cachewarmup',
'app-migrate' => 'PrietoTasks\Migrate',
],
If I try to list the commands, the "app-warmup" is shown as "app:warmup", which is fine. Doing a "rocketeer" command:
app
app:migrate Migrates the database
app:warmup Warms up the cache
But if I do a rocketeer app:warmup --on="production" -vvv
the executed command is wrong:
rocketeer app:warmup --on="production" -vvv
| Closure (cachewarmup) [~5.46s]
$ cd /var/www/prieto_publisher_test/releases/20150729154612
$ cachewarmup
[deploy@IP] (production) bash: cachewarmup: command not found
Execution time: 5.6189s
It should be php app/console cache:warmup
, not chachewarmup
which is calculated from \Rocketeer\Abstracts\AbstractTask::getName()
Any ideas?
Bump:
I am experiencing the same Issue(s). We use a custom task to import/export a database:
hooks.php
:
'custom' => [
'database-import' => '\Tasks\ImportDatabase',
'database-deploy' => '\Tasks\DeployDatabase',
],
Tasks/DeployDatabase
:
namespace Tasks;
use Rocketeer\Abstracts\AbstractTask;
/**
* Class ImportDatabase
* @package Tasks
*/
class DeployDatabase extends AbstractTask {
protected $local = true;
protected $name = 'database:deploy';
running rocketeer, I get:
database
database:deploy Deploys the local database (in full) to target
database:import Dumps the database from remote, and imports locally
but when attempting to run one of the custom commands, it fails:
$ vendor/bin/rocketeer database:deploy
staging/0 | Closure (databasedeploy)
$ cd /home/deploy/releases/20160901122601
$ databasedeploy
[deploy@stagingserver] (staging) bash: databasedeploy: command not found
Execution time: 1.057s
I've tried various combos of Class name (camelcase, single upper-case, etc.), but the only work-around I can find is to use all lower-case task names, so that they are included in the main list of tasks like:
Available commands:
check Check if the server is ready to receive the application
cleanup Clean up old releases from the server
current Display what the current release is
databasedeploy Deploys the local database (in full) to target
databaseimport Dumps the database from remote, and imports locally
when hooks.php
looks like this:
'custom' => [
'databaseimport' => '\Tasks\ImportDatabase',
'databasedeploy' => '\Tasks\DeployDatabase',
],