amp-cli / amp Goto Github PK
View Code? Open in Web Editor NEWControl script for *amp-style stacks
Control script for *amp-style stacks
Discussed in #21
.htaccess
amp test
fails if you have ~/.amp under and encrypted home directory. Detect this scenario and suggest using AMPHOME environment variable instead to put the config somewhere else.
Is it possible to omit the random characters of the database name created by amp? I have a few database installed with amp and it is hard to remember each random suffix to use in mysql workbench during development and in my case I have made sure that the prefix is unique, e.g. contains a project name
The README.md file needs updating, a lot of the text it contains seems to refer to a 'pre-a;pha' release, and the examples do not seem current anymore.
Just noting that I found I was able to do
amp config:set --mysql_dsn=mysql:://root@database:3306
but
a) it's not in the read me and
b) it only appeared to work AFTER I'd run config::set with db_type
I think it makes sense to update the readme if that is the case
Also the 'pre-alpha' part of the readme is wrong IMHO given we use this daily
I was getting 500s on front page - the following change makes NginX behave better for me.
Also provides NginX with a deny rule for sites/default/files/civicrm
I installed amp
with buildkit
and then I ran amp config
and got the following services.yml :
parameters:
version: 2
mysql_dsn: 'mysql://root:<passwd>@localhost:3306'
perm_type: worldWritable
httpd_type: apache24
db_type: mysql_dsn
services: { }
This is a local mariadb installation and I am fairly certain the DSN is correct.
Now, when i run amp test
I get:
ajk@ajk-ThinkPad-R60:~/buildkit$ amp test
Create test application
Create data directory: /home/ajk/.amp/canary/data/Av5ikz5lpujbK0fgNpOgMv5J1HOGj0aJ
AMP_URL='http://localhost:7979'
AMP_ROOT='/home/ajk/.amp/canary'
AMP_DB_DSN='mysql://canary_81ukt:[email protected]:3306/canary_81ukt?new_link=true'
AMP_DB_USER='canary_81ukt'
AMP_DB_PASS='gW9CB6OqPf8hUsix'
AMP_DB_HOST='127.0.0.1'
AMP_DB_PORT='3306'
AMP_DB_NAME='canary_81ukt'
AMP_DB_ARGS='-h 127.0.0.1 -u canary_81ukt -pgW9CB6OqPf8hUsix -P 3306 canary_81ukt'
Connect to test application
Expect response: "response-code-QY8FMePLvE"
PHP Warning: file_get_contents(http://localhost:7979/index.php): failed to open stream: HTTP request failed! HTTP/1.0 500 Internal Server Error
in phar:///home/ajk/buildkit/bin/amp/src/Amp/Command/TestCommand.php on line 153
PHP Stack trace:
PHP 1. {main}() /home/ajk/buildkit/bin/amp:0
PHP 2. require() /home/ajk/buildkit/bin/amp:10
PHP 3. Amp\Application::main() phar:///home/ajk/buildkit/bin/amp/bin/amp:18
PHP 4. Symfony\Component\Console\Application->run() phar:///home/ajk/buildkit/bin/amp/src/Amp/Application.php:49
PHP 5. Symfony\Component\Console\Application->doRun() phar:///home/ajk/buildkit/bin/amp/vendor/symfony/console/Symfony/Component/Console/Application.php:124
PHP 6. Symfony\Component\Console\Application->doRunCommand() phar:///home/ajk/buildkit/bin/amp/vendor/symfony/console/Symfony/Component/Console/Application.php:193
PHP 7. Symfony\Component\Console\Command\Command->run() phar:///home/ajk/buildkit/bin/amp/vendor/symfony/console/Symfony/Component/Console/Application.php:889
PHP 8. Amp\Command\TestCommand->execute() phar:///home/ajk/buildkit/bin/amp/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:252
PHP 9. Amp\Command\TestCommand->doPost() phar:///home/ajk/buildkit/bin/amp/src/Amp/Command/TestCommand.php:78
PHP 10. file_get_contents() phar:///home/ajk/buildkit/bin/amp/src/Amp/Command/TestCommand.php:153
Warning: file_get_contents(http://localhost:7979/index.php): failed to open stream: HTTP request failed! HTTP/1.0 500 Internal Server Error
in phar:///home/ajk/buildkit/bin/amp/src/Amp/Command/TestCommand.php on line 153
Call Stack:
0.0003 125200 1. {main}() /home/ajk/buildkit/bin/amp:0
0.0227 240376 2. require('phar:///home/ajk/buildkit/bin/amp/bin/amp') /home/ajk/buildkit/bin/amp:10
0.0336 488304 3. Amp\Application::main() phar:///home/ajk/buildkit/bin/amp/bin/amp:18
0.2386 2502380 4. Symfony\Component\Console\Application->run() phar:///home/ajk/buildkit/bin/amp/src/Amp/Application.php:49
0.2395 2505484 5. Symfony\Component\Console\Application->doRun() phar:///home/ajk/buildkit/bin/amp/vendor/symfony/console/Symfony/Component/Console/Application.php:124
0.2398 2505656 6. Symfony\Component\Console\Application->doRunCommand() phar:///home/ajk/buildkit/bin/amp/vendor/symfony/console/Symfony/Component/Console/Application.php:193
0.2399 2505200 7. Symfony\Component\Console\Command\Command->run() phar:///home/ajk/buildkit/bin/amp/vendor/symfony/console/Symfony/Component/Console/Application.php:889
0.2407 2506616 8. Amp\Command\TestCommand->execute() phar:///home/ajk/buildkit/bin/amp/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:252
0.3187 2812180 9. Amp\Command\TestCommand->doPost() phar:///home/ajk/buildkit/bin/amp/src/Amp/Command/TestCommand.php:78
0.3187 2813684 10. file_get_contents() phar:///home/ajk/buildkit/bin/amp/src/Amp/Command/TestCommand.php:153
Received incorrect response: ""
Tip: Try running "amp config" and/or restarting the webserver.
ajk@ajk-ThinkPad-R60:~/buildkit$
I am not sure what the issue is. The error message isn't very helpful.
I installed all the prerequisites using sudo apt-get install php5-cli php5-imap php5-ldap php5-curl php5-mysql php5-intl php5-gd php5-mcrypt php-apc apache2 libapache2-mod-php5
(as was written in the installer script for buildkit
)
Hey there,
https://12factor.net/logs stats that you should treat logs as streams.
In the Docker apache image this is achieved by symlinking the apache log files to /dev/stderr
and /dev/stdout` see this comment for more details.
By default amp defines its own log files for each site, which overrides the Docker config.
I know that amp isn't primarily aimed at Docker, and that https://12factor.net/logs is not the final word on app design, but I wanted to draw your attention to this in case you had any thoughts / it was helpful in thinking about how amp is designed.
It's not a blocker and I have got round it in the CiviCRM Docker image with a custom apache vhost template michaelmcandrew/civicrm-buildkit-docker@65a0971 (pending this PR).
When I run 'amp test' I receive the error in the title.
It seems that this is because the script is checking the REMOTE_ADDR for 'localhost'. Expect because the request is coming from the command line the REMOTE_ADDR is not being set?
Unless there is something else that might be causing the 403 response at this point.
Any help debugging this would be great. Thanks.
When prompting user for administrative credentials, specify the user credentials required.
Some developers instinctively want to add a new user. Buildkit will do this automatically for each build, but they still want to create a new user for buildkit per-se. We should display instructions for grantin permissions to this user, eg
GRANT ALL ON *.* to '$user'@'localhost' IDENTIFIED BY '$pass' WITH GRANT OPTION
According to https://dev.mysql.com/doc/refman/5.7/en/identifiers.html, mysql database names can be up to 64 characters long. Amp shortens them to something much shorter (I had a quick look but couldn't find where) which means that (in buildkit) the civi cms and test suffixes are often lost, which makes it harder to identify databases.
Can we set the max length to 64?
I use an encrypted home directory which www-data cannot read.
I was able to run fine if I changed:
https://github.com/totten/amp/blob/master/src/Amp/Application.php#L31
to $appDir = '/my/permissionedfolder/amp'; EG: $appDir = '/var/www/vhosts/amp';
I also had to move civicrm-buildkit out of my home folder as well since the test includes the vendor autoload from there.
Perhaps you need a way for users to move out of the home folder if necessary like check for an environment variable such as $AMP_HOME and default to to the user home if it is not set?
Great utility by the way!
After setting up amp in Arch Linux running xampp/lampp I ran amp test
and got
Warning: file_get_contents(http://localhost:7979/index.php): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
in phar:///home/colemanw/buildkit/bin/amp/src/Amp/Command/TestCommand.php on line 163
After a lot of trial-and-error with various apache settings I finally discovered this fix:
chmod +x /home/colemanw
And that solved it so my built sites are now accessible in the web browser.
Suggestion:
Can we add something about this to the output of amp test
on failure? Particularly if the error message contains "403" and we can detect that the +x bit is not set on the home directory.
src/Amp/views/nginx-vhost.php assumes we are running php on port 9000 rather than on a socket. Is there any way that we can test for this and create an appropriate config? Maybe look for
listen = /var/run/php5-fpm.sock
in /etc/php5/fpm/pool.dfpm/pool.d/www.conf or similar?
If not trivial, we should potentially add this as a gotcha or similar in the documentation.
There are several common stacks for doing local development -- e.g. Debian/Ubuntu, MAMP, XAMPP, MacPorts, etc.
At the start of the amp config
interview, determine if we are in one of these environments. Subsequent suggestions/defaults can be tuned based on this.
(Note: This is not a new issue -- I just moved it from the README's backlog.)
I get the above error after running amp config
and then amp test
. I'm fairly sure the configuration values for amp config
are correct. Any suggestion of where I could look to fix this?
The complete output of amp test
is this:
as@as76:~$ amp test
Create test application
Create data directory: /home/as/.amp/canary/data/KvCDB9TIuN1rHpQHm0IqbMRjGwxLOrWo
AMP_URL='http://localhost:7979'
AMP_ROOT='/home/as/.amp/canary'
AMP_DB_DSN='mysql://canary_22i7b:[email protected]:3306/canary_22i7b?new_link=true'
AMP_DB_USER='canary_22i7b'
AMP_DB_PASS='TzClEIZZgAeHRpGP'
AMP_DB_HOST='127.0.0.1'
AMP_DB_PORT='3306'
AMP_DB_NAME='canary_22i7b'
AMP_DB_ARGS='-h 127.0.0.1 -u canary_22i7b -pTzClEIZZgAeHRpGP -P 3306 canary_22i7b'
Connect to test application
Expect response: "response-code-eAh4Poer5l"
PHP Warning: file_get_contents(http://localhost:7979/index.php): failed to open stream: Connection refused in /opt/buildkit/vendor/totten/amp/src/Amp/Command/TestCommand.php on line 153
Warning: file_get_contents(http://localhost:7979/index.php): failed to open stream: Connection refused in /opt/buildkit/vendor/totten/amp/src/Amp/Command/TestCommand.php on line 153
Received incorrect response: ""
Tip: Try running "amp config" and/or restarting the webserver.
I was trying amp config
and while running tried the "MySQL based on existing configuration" option.
amp config
and used mysql_dsn.amp test
and it said it was not able to connect to the mysqlamp config
again and tried mysql_cfg
amp
command (including amp -h
) throws an error.The error I get:
ajk@ajk-ThinkPad-R60:~/buildkit$ amp config
PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Failed to locate MySQL service via ~/.my.cnf' in phar:///home/ajk/buildkit/bin/amp/src/Amp/Database/MySQLCnfFactory.php:16
Stack trace:
#0 [internal function]: Amp\Database\MySQLCnfFactory::get()
#1 phar:///home/ajk/buildkit/bin/amp/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php(951): call_user_func_array(Array, Array)
#2 phar:///home/ajk/buildkit/bin/amp/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php(488): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), 'db.mysql_mycnf')
#3 phar:///home/ajk/buildkit/bin/amp/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php(472): Symfony\Component\DependencyInjection\ContainerBuilder->get(Object(Symfony\Component\DependencyInjection\Alias))
#4 phar:///home/ajk/buildkit/bin/amp/vendor/symfony/dependency-injec in phar:///home/ajk/buildkit/bin/amp/src/Amp/Database/MySQLCnfFactory.php on line 16
Fatal error: Uncaught exception 'RuntimeException' with message 'Failed to locate MySQL service via ~/.my.cnf' in phar:///home/ajk/buildkit/bin/amp/src/Amp/Database/MySQLCnfFactory.php on line 16
RuntimeException: Failed to locate MySQL service via ~/.my.cnf in phar:///home/ajk/buildkit/bin/amp/src/Amp/Database/MySQLCnfFactory.php on line 16
Call Stack:
0.0003 125104 1. {main}() /home/ajk/buildkit/bin/amp:0
0.0227 240268 2. require('phar:///home/ajk/buildkit/bin/amp/bin/amp') /home/ajk/buildkit/bin/amp:10
0.0332 488232 3. Amp\Application::main() phar:///home/ajk/buildkit/bin/amp/bin/amp:18
0.0333 488872 4. Amp\Application->__construct() phar:///home/ajk/buildkit/bin/amp/src/Amp/Application.php:46
0.1894 1669624 5. Amp\Application->createCommands() phar:///home/ajk/buildkit/bin/amp/src/Amp/Application.php:62
0.2059 1918680 6. Symfony\Component\DependencyInjection\ContainerBuilder->get() phar:///home/ajk/buildkit/bin/amp/src/Amp/Application.php:152
Key points:
Currently we have to pre-create a services.xml in order to pre-determine the db user name / password but it feels like civibuild should accept these as inputs. I understand the reasons for generating unique names but there are also good reasons for wanting consistent names in developer / ci environments at times
I believe the input is somewhere near here
https://github.com/amp-cli/amp/blob/master/src/Amp/Database/MySQL.php#L55
but I want to know there is not a reason NOT to add that option @totten
If you try to use Drupal without mod_rewrite, the site will nominally display, but you won't be able to login or do anything substantive. We should either:
amp config
)amp test
)Is it correct to assume app/default/services is distributed? In other words if Amp is packaged, would it be distributed to every installation of Amp? I ask because a simple config command would not put ram_disk_type in my .amp repo, but Application.php assumes it's available.
In file: app/defaults/services.yml, shouldn't we have:
Otherwise amp is only usable if you are root.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.