Production


Set up a load balancer on Laravel Forge

Laravel Forge is a deployment tool that’s used on some of our sites. To set up a load balancer:

  1. Log in to Laravel Forge
  2. Spin up 2+ servers to balance, and give them the same domain name.
    2.1 In the servers’ settings, go to the Network section (from the menu on the left) and check the other load balanced server, then “Update Network”. Do this for ALL of the servers that you wish to balance.
  3. Spin up a new server, and check the “provision as load balancer” check box.
  4. Go into the load balancer server and enter the root domain, the same domain name as the servers you set up in step 2, then click “Add Site”
  5. Once it’s done provisioning, click the link to the new “site”. In the settings page that appears, check the servers that you wish to balance, then click “Update Balanced Servers”

Set up cron jobs on Laravel Forge

  1. Log in to Laravel Forge
  2. Locate the server your project is on
  3. Navigate to the “Scheduler” from the sidebar
  4. Edit/enter the command. For example, to run scheduled commands for the project named project.code413.io, enter php/home/forge/api.code413.io/artisan schedule:run
    Note: To check your project’s directory:

    1. SSH into the server
    2. Navigate to your project
    3. Use the pwd command to print the full directory to your console.
  5. Change the value in the “User” input if necessary

  6. Select a frequency

  7. Click “Schedule Job”

  8. Once it’s done setting up, you can find the list of cron jobs at the lower part of the page. Click the little green “log” icon towards the right to check if your cron jobs are working.