### Prepare Database and Start App Source: https://github.com/antiwork/gumroad/blob/main/docs/development/windows.md Installs necessary development libraries, prepares the Rails database by creating it if it doesn't exist and running migrations, and then starts the Rails development server. ```bash sudo apt install libxslt-dev libxml2-dev bin/rails db:prepare bin/dev ``` -------------------------------- ### Setup Test Environment Dependencies Source: https://github.com/antiwork/gumroad/blob/main/README.md Commands to set up the local environment for running tests, including starting Docker services, setting up the test database, and generating JS constants. ```shell make local # start Docker services (db, Redis, etc.) RAILS_ENV=test bin/rails db:setup # set up the test database RAILS_ENV=test bin/rails js:export # generate JS constants for the test environment ``` -------------------------------- ### Install Bundler and Ruby Gems Source: https://github.com/antiwork/gumroad/blob/main/README.md Installs the Bundler gem and then installs all project-specific Ruby gems defined in the Gemfile. ```shell gem install bundler bundle install ``` -------------------------------- ### Install Node.js with nvm Source: https://github.com/antiwork/gumroad/blob/main/docs/development/windows.md Installs Node Version Manager (nvm) and then installs and uses a specific Node.js version. Ensure to source ~/.bashrc after installation. ```bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash source ~/.bashrc nvm install 20.17.0 nvm use 20.17.0 ``` -------------------------------- ### Install MySQL Client Libraries Source: https://github.com/antiwork/gumroad/blob/main/docs/development/windows.md Installs the MySQL client libraries and the mysql-client package, which are needed for database connectivity. ```bash sudo apt install libmysqlclient-dev mysql-client ``` -------------------------------- ### Install WSL and Ubuntu Source: https://github.com/antiwork/gumroad/blob/main/docs/development/windows.md Installs the Windows Subsystem for Linux and Ubuntu. This is a prerequisite for running the development environment. ```bash wsl --install ``` -------------------------------- ### Start Redis Service with Launchd Source: https://github.com/antiwork/gumroad/blob/main/docs/setup_without_docker/mac.md Configures launchd to start the Redis service automatically on login and starts it immediately. This ensures Redis is running when needed. ```bash brew services start redis ``` -------------------------------- ### Install Redis using Homebrew Source: https://github.com/antiwork/gumroad/blob/main/docs/setup_without_docker/mac.md Installs the Redis service using Homebrew. This is a prerequisite for running the Redis server. ```bash brew install redis ``` -------------------------------- ### Install Ruby Gems Source: https://github.com/antiwork/gumroad/blob/main/docs/development/windows.md Installs the Bundler gem for managing Ruby dependencies, then installs all project gems using Bundler, and finally installs the dotenv gem. ```bash gem install bundler bundle install gem install dotenv ``` -------------------------------- ### Start Generic Web Server for Long-Running Tasks Source: https://github.com/antiwork/gumroad/blob/main/docs/migrations.md Use this command to set the deployment tag and start a generic web server for long-running tasks. Ensure no other instance is running before redeploying. ```bash export DEPLOY_TAG=production- cd nomad/production && ./start_generic_web.sh ``` -------------------------------- ### Install Percona Toolkit Source: https://github.com/antiwork/gumroad/blob/main/docs/development/windows.md Installs the Percona Toolkit, a collection of advanced command-line tools for MySQL and MariaDB. ```bash sudo apt install percona-toolkit ``` -------------------------------- ### Install MySQL and Percona Toolkit Source: https://github.com/antiwork/gumroad/blob/main/docs/setup_without_docker/mac.md Installs MySQL and Percona Toolkit using Homebrew and forces the linking of MySQL. This is the initial step for setting up the MySQL service. ```bash brew install mysql percona-toolkit brew link --force mysql ``` -------------------------------- ### Create .env file Source: https://github.com/antiwork/gumroad/blob/main/docs/development/windows.md Copies the example environment file to .env. This file is used to store sensitive information and configuration settings. ```bash cp .env.example .env ``` -------------------------------- ### Install FFmpeg on Linux Source: https://github.com/antiwork/gumroad/blob/main/README.md Installs the FFmpeg package on a Debian-based Linux system using apt-get. ```shell sudo apt-get install ffmpeg ``` -------------------------------- ### Start Docker Services Source: https://github.com/antiwork/gumroad/blob/main/README.md Use this command to start Docker services for local development. On Linux, you might need to use sudo. ```shell make local ``` -------------------------------- ### Install Elasticsearch Full Source: https://github.com/antiwork/gumroad/blob/main/docs/setup_without_docker/mac.md Installs the full Elasticsearch package using a Homebrew tap. This command sets up Elasticsearch for local development. ```bash brew tap elastic/tap brew install elastic/tap/elasticsearch-full ``` -------------------------------- ### Start the Application Source: https://github.com/antiwork/gumroad/blob/main/README.md Starts the Rails server, JavaScript build system, and Sidekiq worker. Access the application at http://localhost:3000. ```shell bin/dev ``` -------------------------------- ### Install pdftk on Linux Source: https://github.com/antiwork/gumroad/blob/main/README.md Installs the pdftk package on a Debian-based Linux system using apt-get. ```shell sudo apt-get install pdftk ``` -------------------------------- ### Install wkhtmltopdf on Linux Source: https://github.com/antiwork/gumroad/blob/main/README.md Installs the wkhtmltopdf package on a Debian-based Linux system using apt-get. ```shell sudo apt-get install wkhtmltopdf ``` -------------------------------- ### Install Docker on Linux Source: https://github.com/antiwork/gumroad/blob/main/README.md Installs Docker on a Linux system and adds the current user to the docker group for permissions. ```shell sudo wget -qO- https://get.docker.com/ | sh sudo usermod -aG docker $(whoami) ``` -------------------------------- ### Install libvips on Linux Source: https://github.com/antiwork/gumroad/blob/main/README.md Installs the libvips development package on a Debian-based Linux system using apt-get. ```shell sudo apt-get install libvips-dev ``` -------------------------------- ### Run Supporting Services Source: https://github.com/antiwork/gumroad/blob/main/docs/debugging.md Execute this command in a terminal to start the supporting services required for local development. ```bash make local ``` -------------------------------- ### Install dotenv gem Source: https://github.com/antiwork/gumroad/blob/main/README.md Installs the dotenv gem, which is required for certain console commands. ```shell gem install dotenv ``` -------------------------------- ### Prepare the Database Source: https://github.com/antiwork/gumroad/blob/main/README.md This command prepares the database for local development. Ensure you have the necessary dependencies installed on Debian/Ubuntu. ```shell bin/rails db:prepare ``` -------------------------------- ### Install Image Processing Libraries Source: https://github.com/antiwork/gumroad/blob/main/docs/development/windows.md Installs essential libraries for image and video processing, including build tools, XML/XSLT support, ImageMagick, libvips, FFmpeg, and pdftk. ```bash sudo apt update && sudo apt install -y \ build-essential libxslt-dev libxml2-dev \ imagemagick libvips-dev ffmpeg pdftk ``` -------------------------------- ### Install Ruby with rbenv Source: https://github.com/antiwork/gumroad/blob/main/docs/development/windows.md Installs the base toolchain, rbenv, ruby-build, and necessary development libraries for Ruby. It also initializes rbenv for the shell and installs/sets the global Ruby version. ```bash sudo apt update sudo apt install -y \ rbenv ruby-build git \ build-essential autoconf bison libssl-dev zlib1g-dev \ libreadline-dev libyaml-dev libffi-dev libgmp-dev export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)" rbenv install 3.4.3 rbenv global 3.4.3 ``` -------------------------------- ### Start Docker Services Source: https://github.com/antiwork/gumroad/blob/main/docs/development/windows.md Starts the Docker services required for the local development environment in detached mode. ```bash LOCAL_DETACHED=true make local ``` -------------------------------- ### Install Node.js Packages Source: https://github.com/antiwork/gumroad/blob/main/docs/development/windows.md Enables corepack for managing package managers and then installs all Node.js project dependencies. ```bash corepack enable npm install ``` -------------------------------- ### Install ImageMagick on Linux Source: https://github.com/antiwork/gumroad/blob/main/README.md Installs the ImageMagick package on a Debian-based Linux system using apt-get. ```shell sudo apt-get install imagemagick ``` -------------------------------- ### Install XQuartz on macOS Source: https://github.com/antiwork/gumroad/blob/main/docs/testing.md Command to install XQuartz on macOS, a dependency for running request specs with Capybara and Selenium. ```bash $ brew install xquartz ``` -------------------------------- ### Start Rpush for Push Notifications Source: https://github.com/antiwork/gumroad/blob/main/README.md Initialize and start Rpush services in the development environment to send push notifications. ```shell INITIALIZE_RPUSH_APPS=true bundle exec rpush start -e development -f ``` -------------------------------- ### Install Google Chrome on Linux Source: https://github.com/antiwork/gumroad/blob/main/docs/testing.md Steps to install Google Chrome stable version on a Debian-based Linux system for integration testing. ```bash $ wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - $ sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' $ sudo apt-get update $ sudo apt-get install google-chrome-stable ``` -------------------------------- ### Start Rails Console Source: https://github.com/antiwork/gumroad/blob/main/docs/development/windows.md Opens an interactive Ruby on Rails console session for the application. ```bash bin/rails c ``` -------------------------------- ### Install MySQL 8.0 and Percona Toolkit on macOS Source: https://github.com/antiwork/gumroad/blob/main/README.md Installs MySQL 8.0 and Percona Toolkit using Homebrew, links MySQL, and configures the mysql2 gem to use Homebrew's OpenSSL. Ensures MySQL is not running as a service. ```shell brew install mysql@8.0 percona-toolkit brew link --force mysql@8.0 # to use Homebrew's `openssl`: brew install openssl bundle config --global build.mysql2 --with-opt-dir="$(brew --prefix openssl)" # ensure MySQL is not running as a service brew services stop mysql@8.0 ``` -------------------------------- ### Run Puma Server with Memory Profiling Source: https://github.com/antiwork/gumroad/blob/main/docs/memory_profiling.md Start the Puma web server within the Docker instance using a custom script that enables memory usage tracking. Ensure ngrok is running and configured. ```bash screen -S puma bash cd /app RAILS_ENV= CUSTOM_DOMAIN= PUMA_WORKER_PROCESSES= ./bin/memusg.sh ./docker/web/server.sh ``` -------------------------------- ### Mobile-First Responsive Design Example Source: https://github.com/antiwork/gumroad/blob/main/docs/prompts/tailwindcss.md Demonstrates the correct way to apply responsive prefixes in Tailwind CSS. Only use prefixes like `sm:`, `md:`, `lg:` where values change, and avoid prefixing utilities that maintain the same value across breakpoints. ```html ``` -------------------------------- ### Install Specific MongoDB Version Source: https://github.com/antiwork/gumroad/blob/main/docs/setup_without_docker/mac.md Installs a specific version of MongoDB Community Edition using a Homebrew tap. Replace '3.6' with the desired version number. ```bash brew install mongodb/brew/mongodb-community@3.6 ``` -------------------------------- ### Example Markdown Image Reference Source: https://github.com/antiwork/gumroad/blob/main/CONTRIBUTING.md This markdown snippet shows how to reference media files stored in the 'qa-media/' directory within a pull request description. Ensure the branch name and file extension are correctly specified. ```markdown ![description](https://raw.githubusercontent.com/antiwork/gumroad//qa-media/pr-5160-pagination-page1.png) ``` -------------------------------- ### Configure MySQL with Homebrew's OpenSSL Source: https://github.com/antiwork/gumroad/blob/main/docs/setup_without_docker/mac.md Installs OpenSSL via Homebrew and configures the MySQL build to use it. This ensures compatibility and proper linking of OpenSSL libraries for MySQL. ```bash # to use Homebrew's `openssl`: brew install openssl bundle config --global build.mysql2 --with-opt-dir="$(brew --prefix openssl)" ``` -------------------------------- ### Run Non-Rails Services Source: https://github.com/antiwork/gumroad/blob/main/docs/debugging.md Use this command to run the non-Rails services, typically part of the application's backend setup. ```bash foreman start -f Procfile.debug ``` -------------------------------- ### Rebase Branch onto Main Source: https://github.com/antiwork/gumroad/blob/main/CONTRIBUTING.md Rebase your branch onto the main branch before starting work and before every commit to ensure your branch is up-to-date and to resolve conflicts locally. ```bash git fetch origin git rebase origin/main ``` -------------------------------- ### Get User's Annual Sales Report URL Source: https://github.com/antiwork/gumroad/blob/main/docs/support.md Retrieve a URL for a user's annual sales report for a specified year. Ensure the year is provided as an argument. ```ruby User.find_by(email: "creator@example.com").financial_annual_report_url_for(year: 2024) ``` -------------------------------- ### Download and Run Docker Instance Source: https://github.com/antiwork/gumroad/blob/main/docs/memory_profiling.md Pull the Gumroad web Docker image and run it with necessary configurations for local development and memory profiling. ```bash docker pull gumroad/web:- ``` ```bash make local # In a seperate window ``` ```bash docker run -it -e BUILD_JS=1 -e RAILS_LOG_LEVEL=error --shm-size=256m -p 3000:3000 --network web_default gumroad/web:- /bin/bash ``` -------------------------------- ### PayPal SDK Configuration (Ruby) Source: https://github.com/antiwork/gumroad/blob/main/docs/paypal.md Configure the PayPal SDK for sandbox environment using provided credentials. This file should be placed in `config/initializers/`. ```ruby PAYPAL_ENDPOINT = "" PAYPAL_REST_ENDPOINT = "" PAYPAL_ENV = "sandbox" PAYPAL_CLIENT_ID = "AQiKjZAqXGcN_oU8wh-RKelv6Nf3IrWVY9J9rrhz1pF7aqiyZjutSdG75I6ahd3zJe1ThpklFp5jNman" PAYPAL_CLIENT_SECRET = "EPnNdtAW6jsUleHWQmjsFNef37f1GGWLwtJx3uO2PRdbENAFxTgW1WA1V83MVYvSrRrkH0tXNevE0CJ_" PAYPAL_LIB_MODE = "sandbox" PAYPAL_URL = "" PAYPAL_MERCHANT_ID = "5SCHBGJUCTP2U" PAYPAL_USER_EMAIL = "paypal-facilitator@gumroad.com" PAYPAL_USER = "paypal-facilitator_api1.gumroad.com" PAYPAL_PASS = "1383112423" PAYPAL_SIGNATURE = "AFcWxV21C7fd0v3bYYYRCpSSRl31A9TRhGDrqj7x7lF9P6NGOruW.7ak" PayPal::SDK.configure( :mode => PAYPAL_ENV, :client_id => PAYPAL_CLIENT_ID, :client_secret => PAYPAL_CLIENT_SECRET, :username => PAYPAL_USER, :password => PAYPAL_PASS, :signature => PAYPAL_SIGNATURE ) ``` -------------------------------- ### Access Staging Logs Source: https://github.com/antiwork/gumroad/blob/main/docs/logs.md Navigate to the staging directory and execute the logs script. ```bash cd nomad/staging && ./logs.sh ``` -------------------------------- ### Add Host Entry for Local Custom Domain Source: https://github.com/antiwork/gumroad/blob/main/docs/testing.md To set up a custom domain on your local environment, add this entry to your /etc/hosts file. This maps a custom domain to your local machine. ```text 127.0.0.1 sample-custom-domain.example.com ``` -------------------------------- ### Remove Browser GUID Ban Source: https://github.com/antiwork/gumroad/blob/main/docs/testing.md Execute this Ruby code in a Rails console to unblock a browser GUID after purchase attempts fail. This involves finding and destroying the blocked object and then deleting the associated purchase record. ```ruby purchase = Purchase.last BlockedObject.browser_guid.active.find_by(guid: purchase.browser_guid).destroy purchase.destroy ``` -------------------------------- ### Access Production Logs Source: https://github.com/antiwork/gumroad/blob/main/docs/logs.md Navigate to the production directory and execute the logs script. ```bash cd nomad/production && ./logs.sh ``` -------------------------------- ### Kill Process on Port 8080 Source: https://github.com/antiwork/gumroad/blob/main/docs/development/windows.md Finds and kills the process currently occupying port 8080. This is useful if the port is already in use and preventing the application from starting. ```bash sudo lsof -i :8080 kill -9 ``` -------------------------------- ### Access Nomad Production Environment Source: https://github.com/antiwork/gumroad/blob/main/docs/alerts.md Navigate to the Nomad directory, source the proxy functions, and enable the production proxy to access container statistics via Hashi-UI. ```bash cd nomad source nomad_proxy_functions.sh proxy_on production ``` -------------------------------- ### Retrieve User's Current Checkout Email Source: https://github.com/antiwork/gumroad/blob/main/docs/support.md Get the email address currently associated with a user's active cart. This is a preliminary step before updating the email. ```ruby User.find_by(email: "customer@example.com").alive_cart.email ``` -------------------------------- ### Update Webhook Event Types Source: https://github.com/antiwork/gumroad/blob/main/docs/paypal.md Modify the event types for an existing webhook. This example replaces the current event types with a new list. Ensure you have the correct `` and a valid ``. ```bash curl -v -X PATCH \ -H "Content-Type:application/json" \ -H "Authorization: Bearer " \ -d '[ { "op": "replace", "path": "/event_types", "value": [ { "name": "CHECKOUT.ORDER.PROCESSED" }, { "name":"CUSTOMER.DISPUTE.CREATED" }, { "name":"CUSTOMER.DISPUTE.RESOLVED" }, { "name":"CUSTOMER.DISPUTE.UPDATED" }, { "name": "MERCHANT.PARTNER-CONSENT.REVOKED" }, { "name": "PAYMENT.CAPTURE.COMPLETED" }, { "name": "PAYMENT.CAPTURE.DENIED" }, { "name":"PAYMENT.CAPTURE.PENDING" }, { "name": "PAYMENT.CAPTURE.REFUNDED" }, { "name":"PAYMENT.CAPTURE.REVERSED" }, { "name":"PAYMENT.ORDER.CREATED" }, { "name": "PAYMENT.REFERENCED-PAYOUT-ITEM.COMPLETED" } ] } ]' ``` -------------------------------- ### Deploy Hotfix to Production Source: https://github.com/antiwork/gumroad/blob/main/docs/deploying.md Set the deployment tag and execute the unattended deployment script. Ensure the 'docker_asset_compile' job in Buildkite has finished. ```bash export DEPLOY_TAG="production-xxxxxxx" cd nomad/production && dotenv -f ../.env ./deploy_unattended.sh ``` -------------------------------- ### Get Last 5 Payouts for User Source: https://github.com/antiwork/gumroad/blob/main/docs/support.md Retrieves details of the last 5 payouts for a specific user, selecting key fields like ID, creation date, processor, amount, currency, and state. ```ruby User.find_by(email: 'creator@example.com').payments.select(:id, :created_at, :processor, :amount_cents, :currency, :state).last(5) ``` -------------------------------- ### Run Full Test Suite Source: https://github.com/antiwork/gumroad/blob/main/README.md Execute the complete suite of RSpec tests for the project. ```shell bin/rspec ``` -------------------------------- ### Run ngrok for Local Tunneling Source: https://github.com/antiwork/gumroad/blob/main/docs/memory_profiling.md Expose your local development server running on port 3000 to the internet using ngrok. This is necessary for simulating external access during testing. ```bash ngrok http 3000 ``` -------------------------------- ### SSH into Server and Open Rails Console Source: https://github.com/antiwork/gumroad/blob/main/docs/migrations.md Connect to the server using the obtained client IP address and open the Rails console. This session remains active even if the connection is interrupted. ```bash INSTANCE_IP=10.1.x.x COMMAND="screen -adR" ./console.sh bundle exec rails c ``` -------------------------------- ### Run Automatic Deployment Source: https://github.com/antiwork/gumroad/blob/main/docs/deploying.md Use this script for simple deployments of verified commits. It will prompt for confirmation of which commits to deploy. It can be run from any branch. ```bash bin/deploy ``` -------------------------------- ### Run the entire RSpec test suite Source: https://github.com/antiwork/gumroad/blob/main/docs/testing.md Execute all tests in the project using the RSpec command. ```bash $ bin/rspec ``` -------------------------------- ### Charge a Subscription Source: https://github.com/antiwork/gumroad/blob/main/docs/testing.md Run this Ruby code in a Rails console to charge a subscription. If making multiple purchases quickly, consider commenting out purchase model validations. ```ruby sub = Subscription.last.charge! sub.charge! ``` -------------------------------- ### Configure Elasticsearch Java Options and Discovery Source: https://github.com/antiwork/gumroad/blob/main/docs/setup_without_docker/mac.md Sets environment variables for Elasticsearch's Java heap size and discovery type. This is typically added to shell configuration files like .bashrc or .zshrc. ```bash export ES_JAVA_OPTS=-Xms512m -Xmx512m export discovery.type=single-node ``` -------------------------------- ### Manual Production Deployment Source: https://github.com/antiwork/gumroad/blob/main/docs/deploying.md Rebase the staging branch into production and then execute the manual deployment script. Verify the deployment in the Nomad-UI by checking for the production docker image with the correct git short SHA. ```bash cd nomad/production && dotenv -f ../.env ./deploy_unattended.sh ``` -------------------------------- ### Enable Pre-commit Hooks Source: https://github.com/antiwork/gumroad/blob/main/docs/development/windows.md Configures Git to use the local .githooks directory for pre-commit hooks, ensuring code quality checks are performed before commits. ```bash git config --local core.hooksPath .githooks ``` -------------------------------- ### Generate Monthly US State Sales Report (Ruby) Source: https://github.com/antiwork/gumroad/blob/main/docs/accounting.md Triggers an asynchronous job to create a monthly sales report for a specific US state. This does not require a long-running task. ```ruby CreateUsStateMonthlySalesReportsJob.perform_async("WA", 8, 2022) ``` ```ruby states = ["NV", "TX", "RI"] months = [1, 2, 3] year = 2025 states.each do |state| months.each do |month| CreateUsStateMonthlySalesReportsJob.perform_async(state, month, year) end end ``` -------------------------------- ### Disable Rack Timeout for Testing Source: https://github.com/antiwork/gumroad/blob/main/docs/testing.md Configure local environment to disable Rack timeout by creating a .env.test.local file. ```text DISABLE_RACK_TIMEOUT="1" ``` -------------------------------- ### Retrieve SSL Certificates Source: https://github.com/antiwork/gumroad/blob/main/docs/alerts.md Connect to a hostname and port to check or retrieve its SSL certificates. This is useful for verifying SSL configurations. ```bash openssl s_client -showcerts -connect [host]:[port] ``` -------------------------------- ### Registering Apple Pay Domain via Rails Console Source: https://github.com/antiwork/gumroad/blob/main/docs/apple_pay.md Use this command in the Rails console to register a custom domain for Apple Pay. Ensure the domain is correctly specified. ```ruby Stripe::ApplePayDomain.create(domain_name: domain) ``` -------------------------------- ### Check Port Connectivity Source: https://github.com/antiwork/gumroad/blob/main/docs/alerts.md Verify if a specific port is open and reachable on a given host. The -z flag attempts connection without sending data, and -w sets a 5-second timeout. ```bash nc -z -w 5 [host] [port] ``` -------------------------------- ### Manually Lock Deployment Source: https://github.com/antiwork/gumroad/blob/main/docs/deploying.md Execute this script to manually lock the deployment process. This is useful if the automatic lock fails or if manual intervention is required. ```bash cd nomad/production && ./lock_deployment.sh ``` -------------------------------- ### Fetch Registered Webhooks Source: https://github.com/antiwork/gumroad/blob/main/docs/paypal.md Retrieve a list of all webhooks registered for your PayPal account. Ensure you have a valid ``. ```bash curl -v -X GET \ -H "Content-Type:application/json" \ -H "Authorization: Bearer " ``` -------------------------------- ### Generate Monthly US States Sales Summary Report Source: https://github.com/antiwork/gumroad/blob/main/docs/accounting.md Use this to generate a monthly summary report for all US states. It requires a list of state codes and the month and year for the report. ```ruby subdivision_codes = Compliance::Countries::TAXABLE_US_STATE_CODES CreateUsStatesSalesSummaryReportJob.perform_async(subdivision_codes, 3, 2024) ``` -------------------------------- ### Manually Unlock Deployment Source: https://github.com/antiwork/gumroad/blob/main/docs/deploying.md Run this script to manually unlock the deployment process after a lock has been applied. Ensure this is done after the deployment is complete or has been resolved. ```bash cd nomad/production && ./unlock_deployment.sh ``` -------------------------------- ### Run Test Confidence Tool Source: https://github.com/antiwork/gumroad/blob/main/CONTRIBUTING.md Execute the test-confidence tool before each commit to assess code quality and test coverage. It helps determine the risk level and necessary tests for confidence milestones. ```bash bin/test-confidence # Run to 99%, stop bin/test-confidence --full # Run to 100% ``` -------------------------------- ### Generate Sales Report for Specific Country and Date Range Source: https://github.com/antiwork/gumroad/blob/main/docs/accounting.md Generates a sales report for a specified country within a custom date range. This runs as an asynchronous job and sends a Slack notification upon completion with a download URL. Use 'all_sales' for all sales or 'discover_sales' for discover sales only. ```ruby GenerateSalesReportJob.perform_async("JP", "2025-1-1", "2025-1-31", "all_sales") ``` ```ruby GenerateSalesReportJob.perform_async("SG", "2024-1-1", "2025-6-30", "discover_sales") ``` -------------------------------- ### Find Large Files on Server Source: https://github.com/antiwork/gumroad/blob/main/docs/alerts.md Identify files larger than 20MB to diagnose disk space issues. Examine the output carefully before removing any files. ```bash sudo find / -type f -size +20M -exec ls -lh {} \; ``` -------------------------------- ### Generate PayPal Access Token Source: https://github.com/antiwork/gumroad/blob/main/docs/paypal.md Use this cURL command to obtain an access token for authenticating API requests. Replace `` and `` with your actual credentials. ```bash curl \ -H "Accept: application/json" \ -H "Accept-Language: en_US" \ -u ":" \ -d "grant_type=client_credentials" ``` -------------------------------- ### Enable Stripe Connect for User Source: https://github.com/antiwork/gumroad/blob/main/docs/support.md Enables Stripe Connect for a specific user by setting their `can_connect_stripe` flag to true. ```ruby User.find_by(email: 'my@email.com').update!(can_connect_stripe: true) ``` -------------------------------- ### Clean Up Old Releases Source: https://github.com/antiwork/gumroad/blob/main/docs/alerts.md Remove old deployment directories to free up disk space. Identify the 'current' release and delete all other directories within the 'releases' folder. If the 'current' release directory is excessively large, a code change and redeploy may be necessary. ```bash grd cd .. ls -l ``` ```bash cd releases ls -l ``` ```bash rm -rf [name] ``` -------------------------------- ### Fetch Webhooks Source: https://github.com/antiwork/gumroad/blob/main/docs/paypal.md Retrieve a list of all registered webhooks for the authenticated account. ```APIDOC ## Fetch Webhooks ### Description Retrieves a list of all registered webhooks for the authenticated account. ### Method GET ### Endpoint https://api.paypal.com/v1/notifications/webhooks ### Parameters #### Header Parameters - **Content-Type** (string) - Required - `application/json` - **Authorization** (string) - Required - `Bearer ` ### Request Example ```bash curl -v -X GET https://api.paypal.com/v1/notifications/webhooks \ -H "Content-Type:application/json" \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **webhook_id** (string) - The unique identifier for the webhook. - **url** (string) - The URL where webhook events are sent. - **event_types** (array) - A list of event types the webhook is subscribed to. ``` -------------------------------- ### Create Hotfix Branch from Non-Release Tag Source: https://github.com/antiwork/gumroad/blob/main/docs/deploying.md Create a hotfix branch from a specific tag when the latest deployment was not a standard 'production-release'. Find the tag name from the #releases Slack channel. ```bash git fetch --tags && git checkout -b comp-assets-hotfix-branch-name production-d6b4605/2018-05-02-13-16-03 ``` -------------------------------- ### Hotfix Workers - Commented Out Deployment Steps Source: https://github.com/antiwork/gumroad/blob/main/docs/deploying.md This diff shows how to comment out specific deployment steps in `nomad/common.sh` when hotfixing workers only. This allows for manual deployment. ```diff diff --git a/nomad/common.sh b/nomad/common.sh index bb60a7a598..d128504bca 100644 --- a/nomad/common.sh +++ b/nomad/common.sh @@ -138,26 +138,26 @@ function create_release_tag() { } function gr_deploy() { - check_for_deployment_lock + # check_for_deployment_lock - run_job database_migration + # run_job database_migration - logger "Waiting for db:migrate to complete" + # logger "Waiting for db:migrate to complete" - wait_for_db_migrate + # wait_for_db_migrate - run_job rpush + # run_job rpush run_job sidekiq_worker - if (production_deployment); then - scale_up_web_server_clusters - deploy_to_web_servers - else - deploy_to_web_servers - fi + # if (production_deployment); then + # scale_up_web_server_clusters + # deploy_to_web_servers + # else + # deploy_to_web_servers + # fi - run_job post_deployment + # run_job post_deployment create_release_tag } ``` -------------------------------- ### Register a New Webhook Source: https://github.com/antiwork/gumroad/blob/main/docs/paypal.md Register a new webhook to receive notifications for specific event types. Replace `` with your application's webhook endpoint and ensure the `` is valid. ```bash curl -v -X POST \ -H "Content-Type:application/json" \ -H "Authorization: Bearer " \ -d '{ "url": "https:///paypal-webhook", "event_types": [ { "name": "CHECKOUT.ORDER.PROCESSED" } ] }' ``` -------------------------------- ### Stop Generic Web Server Instance Source: https://github.com/antiwork/gumroad/blob/main/docs/migrations.md Commands to stop the `web_server_generic` instance after the long-running task is finished. This involves proxying and stopping the service. ```bash cd nomad source nomad_proxy_functions.sh proxy_off production; proxy_on production nomad_insecure_wrapper stop -purge web_server_generic proxy_off production ``` -------------------------------- ### Create Hotfix Branch from Production Release Tag Source: https://github.com/antiwork/gumroad/blob/main/docs/deploying.md Use this command to create a hotfix branch when the latest production code is tagged as 'production-release'. ```bash git tag -d production-release git fetch origin tag production-release git checkout -b comp-assets-hotfix-branch-name production-release ``` -------------------------------- ### Run a spec multiple times locally Source: https://github.com/antiwork/gumroad/blob/main/docs/testing.md Loop to run a specific RSpec integration test multiple times to check for flakiness. ```shell for i in {1..10}; do echo "Run number $i\n-" bin/rspec spec/requests/product_creation_spec.rb:28 done ``` -------------------------------- ### Access Screen Session Source: https://github.com/antiwork/gumroad/blob/main/docs/memory_profiling.md Reconnect to an existing screen session to view the output of the running processes, including memory usage statistics. ```bash screen -x puma ``` -------------------------------- ### View Backtrace of a Dead Sidekiq Job Source: https://github.com/antiwork/gumroad/blob/main/docs/sidekiq.md Use this to inspect the error backtrace of a specific dead job. Ensure you have the correct class name and arguments to identify the job. ```ruby ds = Sidekiq::DeadSet.new dead_jobs = ds.select { |job| job.klass == 'ExportUserSalesDataWorker' && job.args[0] == 123 } pp dead_jobs.first.error_backtrace; nil ``` -------------------------------- ### Create Discover Sales Reports Job Source: https://github.com/antiwork/gumroad/blob/main/docs/taxes.md This asynchronous job is responsible for auto-filing taxes for specific US states through TaxJar. It creates TaxJar transaction records. In 2025, this job needs to be updated to include a broader scope of purchases and more states. ```ruby class CreateDiscoverSalesReportsJob < ApplicationJob # ... job implementation ... end ``` -------------------------------- ### Hotfix Sidekiq Worker Deployment Source: https://github.com/antiwork/gumroad/blob/main/docs/deploying.md Manual deployment steps for Sidekiq workers. This involves setting the DEPLOY_TAG, navigating to the nomad directory, sourcing proxy functions, and running the nomad job. ```bash $ export DEPLOY_TAG=<> $ cd nomad $ source nomad_proxy_functions.sh $ cd production $ alias nomad=nomad_insecure_wrapper $ dotenv -f ../.env erb sidekiq_worker.nomad.erb > sidekiq_worker.nomad $ nomad run sidekiq_worker.nomad ```