Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

process_handler

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

process_handler

  • 4.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

ProcessHandler

Build Status Code Climate

ProcessHandler helps to spawn and manage services. There are multiple types of processes. Every process knows how to handle SIGINT and SIGTERM signals.

PivotProcess

This process is used for services that need one or more threads and use the request-response model Freddy.

Example of using pivot process:

  service = MyService.new
  freddy = Freddy.new
  statsd = Statsd.new
  logger = Logasm.build('my-app', {stdout: {level: :debug}})

  process = Salemove::ProcessHandler::PivotProcess.new(
    freddy: freddy,
    logger: logger,
    statsd: statsd
  )
  process.spawn(service)

Service

If you want to use pivot process, then the given service must implement call method that takes input as an argument.

Example of a service:

  class Echo
    def call(input)
      result = # do something with input
      {success: true, output: result} # return result
    end
  end
end

CronProcess

This process allows a service to run recurringly either at times specified by a cron expression or at a fixed time interval: "1" for seconds, "2h" for hours and "2d" for days.

Example of using cron process with cron expressions:

  service = MyService.new

  # every five minutes between 7:00 and 7:55 on Mon to Fri
  process = Salemove::ProcessHandler::CronProcess.new('0/5 7  * * 1-5')
  process.spawn(service)

Example of using cron process with interval expressions:

  service = MyService.new

  # every second hour
  process = Salemove::ProcessHandler::CronProcess.new('2h')
  process.spawn(service)

Service

If you want to use a cron process, then you only must implement call method that does not take any arguments.

Example of a service:

  class MemWatcher
    def call
      result = `sysctl -a | grep 'hw.usermem'`

      # e.g write this result to a file
    end
  end

FAQs

Package last updated on 18 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc