Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save christyjacob4/978eb66f807d7e05dd5084a1d4a5e590 to your computer and use it in GitHub Desktop.
Save christyjacob4/978eb66f807d7e05dd5084a1d4a5e590 to your computer and use it in GitHub Desktop.
Getting started with appwrite
  1. Start your containers
docker-compose up -d
  1. Watch the logs of appwrite_maria_db to ensure that it has started and is ready for requests. The appwrite_maria_db service is usually the last one to start up. So if you make requests before the DB is fully initialised , it leads to a lot of errors. You can access the logs using
docker logs -f appwrite_mariadb_1 

The first time you run docker-compose up, the DBs are initialised from scratch and the first run of the DB service takes around 4 minutes for completion. You don't have to wait this long for subsequent startups.

  • First start up logs
Database initialized
MySQL init process in progress...
2019-10-02 14:31:49 0 [Note] mysqld (mysqld 10.4.4-MariaDB-1:10.4.4+maria~bionic) starting as process 111 ...
2019-10-02 14:31:49 0 [Note] InnoDB: Using Linux native AIO
2019-10-02 14:31:49 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-10-02 14:31:49 0 [Note] InnoDB: Uses event mutexes
2019-10-02 14:31:49 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-10-02 14:31:49 0 [Note] InnoDB: Number of pools: 1
2019-10-02 14:31:49 0 [Note] InnoDB: Using SSE2 crc32 instructions
2019-10-02 14:31:49 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2019-10-02 14:31:49 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
2019-10-02 14:31:50 0 [Note] InnoDB: Completed initialization of buffer pool
2019-10-02 14:31:50 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-10-02 14:31:50 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2019-10-02 14:31:50 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-10-02 14:31:50 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-10-02 14:31:50 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2019-10-02 14:31:50 0 [Note] InnoDB: Waiting for purge to start
2019-10-02 14:31:50 0 [Note] InnoDB: 10.4.4 started; log sequence number 139836; transaction id 21
2019-10-02 14:31:50 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2019-10-02 14:31:50 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-10-02 14:31:50 0 [Warning] 'user' entry 'root@e326af090d88' ignored in --skip-name-resolve mode.
2019-10-02 14:31:50 0 [Warning] 'user' entry '@e326af090d88' ignored in --skip-name-resolve mode.
2019-10-02 14:31:50 0 [Warning] 'proxies_priv' entry '@% root@e326af090d88' ignored in --skip-name-resolve mode.
2019-10-02 14:31:50 0 [Note] InnoDB: Buffer pool(s) load completed at 191002 14:31:50
2019-10-02 14:31:50 0 [Note] Reading of all Master_info entries succeded
2019-10-02 14:31:50 0 [Note] Added new Master_info '' to hash table
2019-10-02 14:31:50 0 [Note] mysqld: ready for connections.
Version: '10.4.4-MariaDB-1:10.4.4+maria~bionic'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  mariadb.org binary distribution
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.

///////////////////// NOTICE THE TIME DIFFERENCE /////////////////////////////////////////
////////////////////// 2 minutes ////////////////////////////////////////////////
2019-10-02 14:33:37 10 [Warning] 'proxies_priv' entry '@% root@e326af090d88' ignored in --skip-name-resolve mode.

/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/all.sql


2019-10-02 14:33:41 0 [Note] mysqld (initiated by: unknown): Normal shutdown
2019-10-02 14:33:41 0 [Note] Event Scheduler: Purging the queue. 0 events
2019-10-02 14:33:41 0 [Note] InnoDB: FTS optimize thread exiting.
2019-10-02 14:33:42 0 [Note] InnoDB: Starting shutdown...
2019-10-02 14:33:42 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
2019-10-02 14:33:42 0 [Note] InnoDB: Buffer pool(s) dump completed at 191002 14:33:42
2019-10-02 14:33:43 0 [Note] InnoDB: Shutdown completed; log sequence number 390687; transaction id 97
2019-10-02 14:33:43 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2019-10-02 14:33:43 0 [Note] mysqld: Shutdown complete
MySQL init process done. Ready for start up.
2019-10-02 14:33:43 0 [Note] mysqld (mysqld 10.4.4-MariaDB-1:10.4.4+maria~bionic) starting as process 1 ...
2019-10-02 14:33:43 0 [Note] InnoDB: Using Linux native AIO
2019-10-02 14:33:43 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-10-02 14:33:43 0 [Note] InnoDB: Uses event mutexes
2019-10-02 14:33:43 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-10-02 14:33:43 0 [Note] InnoDB: Number of pools: 1
2019-10-02 14:33:43 0 [Note] InnoDB: Using SSE2 crc32 instructions
2019-10-02 14:33:43 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2019-10-02 14:33:43 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
2019-10-02 14:33:43 0 [Note] InnoDB: Completed initialization of buffer pool
2019-10-02 14:33:43 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-10-02 14:33:44 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2019-10-02 14:33:44 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-10-02 14:33:44 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-10-02 14:33:44 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2019-10-02 14:33:44 0 [Note] InnoDB: Waiting for purge to start
2019-10-02 14:33:44 0 [Note] InnoDB: 10.4.4 started; log sequence number 390687; transaction id 95
2019-10-02 14:33:44 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2019-10-02 14:33:44 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-10-02 14:33:44 0 [Note] Server socket created on IP: '::'.
2019-10-02 14:33:44 0 [Warning] 'proxies_priv' entry '@% root@e326af090d88' ignored in --skip-name-resolve mode.
2019-10-02 14:33:44 0 [Note] Reading of all Master_info entries succeded
2019-10-02 14:33:44 0 [Note] Added new Master_info '' to hash table
2019-10-02 14:33:44 0 [Note] mysqld: ready for connections.
Version: '10.4.4-MariaDB-1:10.4.4+maria~bionic'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
2019-10-02 14:33:44 0 [Note] InnoDB: Buffer pool(s) load completed at 191002 14:33:44
  • Subsequent startup logs
2019-10-02 14:39:39 0 [Note] mysqld (mysqld 10.4.4-MariaDB-1:10.4.4+maria~bionic) starting as process 1 ...
2019-10-02 14:39:39 0 [Note] InnoDB: Using Linux native AIO
2019-10-02 14:39:39 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-10-02 14:39:39 0 [Note] InnoDB: Uses event mutexes
2019-10-02 14:39:39 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-10-02 14:39:39 0 [Note] InnoDB: Number of pools: 1
2019-10-02 14:39:39 0 [Note] InnoDB: Using SSE2 crc32 instructions
2019-10-02 14:39:39 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2019-10-02 14:39:39 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
2019-10-02 14:39:39 0 [Note] InnoDB: Completed initialization of buffer pool
2019-10-02 14:39:39 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-10-02 14:39:39 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2019-10-02 14:39:39 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-10-02 14:39:39 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-10-02 14:39:39 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2019-10-02 14:39:39 0 [Note] InnoDB: Waiting for purge to start
2019-10-02 14:39:40 0 [Note] InnoDB: 10.4.4 started; log sequence number 390696; transaction id 95
2019-10-02 14:39:40 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2019-10-02 14:39:40 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-10-02 14:39:40 0 [Note] Server socket created on IP: '::'.
2019-10-02 14:39:40 0 [Warning] 'proxies_priv' entry '@% root@e326af090d88' ignored in --skip-name-resolve mode.
2019-10-02 14:39:40 0 [Note] Reading of all Master_info entries succeded
2019-10-02 14:39:40 0 [Note] Added new Master_info '' to hash table
2019-10-02 14:39:40 0 [Note] mysqld: ready for connections.
Version: '10.4.4-MariaDB-1:10.4.4+maria~bionic'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
2019-10-02 14:39:40 0 [Note] InnoDB: Buffer pool(s) load completed at 191002 14:39:40
  1. Now the service is up and running and you would want to make code changes. However you will not be able to because the permissions have been changed. Notice the user www-data
drwxrwxr-x  10 www-data www-data   4096 Oct  1 23:03 app
-rw-rw-r--   1 christy  christy     786 Oct  1 10:43 build.sh
-rw-rw-r--   1 christy  christy     855 Oct  1 23:03 CHANGES.md
-rw-rw-r--   1 christy  christy    3348 Sep 28 10:39 CODE_OF_CONDUCT.md
-rw-rw-r--   1 christy  christy    2169 Sep 28 10:39 composer.json
-rw-rw-r--   1 christy  christy  113899 Oct  2 02:08 composer.lock
-rw-rw-r--   1 christy  christy    6426 Oct  1 20:43 CONTRIBUTING.md
drwxrwxr-x   3 christy  christy    4096 Sep 28 10:39 docker
-rw-rw-r--   1 christy  christy    1834 Sep 28 11:28 docker-compose.yml
-rwxrwxr-x   1 christy  christy    3033 Oct  1 11:00 Dockerfile
drwxrwxr-x   2 christy  christy    4096 Oct  1 21:02 docs
-rw-rw-r--   1 christy  christy    3951 Sep 28 10:39 gulpfile.js
-rw-rw-r--   1 christy  christy    1525 Sep 28 10:39 LICENSE
drwxrwxr-x 593 christy  christy   20480 Sep 28 10:57 node_modules
-rw-rw-r--   1 christy  christy     361 Sep 28 10:39 package.json
-rw-rw-r--   1 christy  christy  304378 Sep 28 10:57 package-lock.json
-rw-rw-r--   1 christy  christy     503 Sep 28 10:39 phpunit.xml
drwxrwxr-x   6 www-data www-data   4096 Sep 28 10:39 public
-rw-rw-r--   1 christy  christy    8668 Oct  2 19:09 README.md
drwxrwxr-x  11 www-data www-data   4096 Sep 28 10:39 src
drwxrwxr-x   9 mysql    mysql      4096 Oct  1 09:44 storage
drwxrwxr-x   4 christy  christy    4096 Sep 28 10:39 tests
drwxrwxr-x  25 www-data www-data   4096 Sep 28 10:54 vendor

To fix those I usually do this

  • Change ownership of the appwrite root directory to me
sudo chown -R christy:christy ./
  • Change the ownership of ./storage/ to the user mysql
sudo chown -R mysql:mysql ./storage/
  1. No you can make code changes and you don't really need to restart the docker containers each time since we have mounted the volume. The changes are automatically reflected in the container!!
  2. Now comes the part on debugging php code. A very useful trick as suggested by eldad is to use var_dump(); followed by an exit(); Let's say you want to debug a variable $foo . You can simply do var_dump($foo); and the output will show up in your browser when you visit that endpoint. exit(); is used to terminate the flow so that you dont get redirected to some other page and you can see the output of var_dump();
  3. If at any point you feel like your code changes are having no effect on the output, then its most likely a cache issue. Clear your browser cache and try again.
  4. Other errors will require further analysis and you can reach out to us on gitter! :)
  5. So In conclusion most of the errors are simply because of permissions or cache not updating. make sure that ./storage is owned by mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment