Skip to content

Instantly share code, notes, and snippets.

@MAnfal
Last active March 8, 2017 07:19
Show Gist options
  • Save MAnfal/4e1720c23c6fca600198623ff1f82c75 to your computer and use it in GitHub Desktop.
Save MAnfal/4e1720c23c6fca600198623ff1f82c75 to your computer and use it in GitHub Desktop.

Initial Setup In Lumen

  • run composer install to install all the important packages, (can be viewed in composer.json).

  • run composer dump-autoload.

  • run php artisan migrate.

  • Install PHPRedis a PHP extension for Redis from https://github.com/phpredis/phpredis.

  • In config/database.php there are following configurations that can be configured for redis.

    • host => IP Address of server where Redis is running.
    • port => Port of server where Redis is running. (By default Redis run on 6379 port)
    • database => Instance to use as database on Redis.
    • password => If password for Redis server is set, then set it's value.
    • read_timeout => Timeout Redis will honor before abandoning lookup for a request in store.
    • token_timeout => Timeout for user device information to stay in Redis store.
    • token_expiry_threshold => Message API will look for this value to decide whether token_timeout for the device shoud be updated or not.
  • In config/push_notification.php following configurations are available for FCM and APNS.

    • apns.certificate_path => by default set to look for APNS generated certificate in StoragePath/certificates.
    • pass_phrase => Generated by APNS alongwith certificate.
    • fcm.api_key => Generated via FCM.
  • API will automatically decide whether to choose sandbox URI of APNS or production based on DEBUG value in env.

  • Set QUEUE_DRIVER=redis in .env file

  • Setup Redis

  • Run Redis

    • cd redis-stable/src
    • run ./redis-server (Redis server is now up).
    • run ./redis-cli (Optional if you want to check redis functionality on CLI otherwise not required).
  • Install and configure Supervisor (A process control system) from http://supervisord.org/installing.html.

  • Configure Supervisor to run following command PHP artisan queue:listen --tries=3 so that if for some reason queues are stopped they are automatically restarted by Supervisor otherwise new push notifications won't be delivered to user.

  • Supervisor configuration

    • Create laravel_worker.conf inside "/etc/supervisor/conf.d/" directory because supervisor listens to this directory by default for new configurations files (For further confirmation check [include] portion in supervisor configuration).
    • Contents of laravel_worker.conf

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /home/gostrive-dev/strive-admin/artisan queue:work redis --sleep=3 --tries=3 --daemon
autostart=true
autorestart=true
user=gostrive-dev
numprocs=8
redirect_stderr=true
stdout_logfile=/home/gostrive-dev/strive-admin/storage/logs/worker.log

  • After creating laravel_worker.conf run following commands

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start laravel-worker:*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment