🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

@openprofiling/trigger-signal

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openprofiling/trigger-signal

This trigger is most probably the easier to use because you just need to send a signal to the process (which is generally straightforward even with containers).

latest
Source
npmnpm
Version
0.2.2
Version published
Maintainers
1
Created
Source

OpenProfiling NodeJS - Signal Trigger

This trigger is most probably the easier to use because you just need to send a signal to the process (which is generally straightforward even with containers).

Advantages

  • No specific setup, one CLI command away

Drawbacks

  • Limited list of signal to listen on (see official doc)
    • I advise to use the SIGUSR1 and SIGUSR2 signal since they are reserved for user-space behavior.
  • Behavior on Windows might be a little more complicated since there a no concept of signals on it (see official doc at the end of the previous link)

How to use

In the following example, when the profile will be done it will be written on disk:

import { ProfilingAgent } from '@openprofiling/nodejs'
import { FileExporter } from '@openprofiling/exporter-file'
import { InspectorCPUProfiler } from '@openprofiling/inspector-cpu-profiler'
import { SignalTrigger } from '@openprofiling/trigger-signal'

const profilingAgent = new ProfilingAgent()
// you just need to precise which signal the trigger need to listen
// little advise: only use SIGUSR1 or SIGUSR2
profilingAgent.register(new SignalTrigger({ signal: 'SIGUSR2' }), new InspectorCPUProfiler())
profilingAgent.start({ exporter: new FileExporter() })

Then to initiate the trigger, just send a signal to the desirated process:

linux/macos:

kill -s USR1 <pid>

You can find the PID via htop, ps aux or just log your process pid with console.log('Process pid is ' + process.pid)` when your application start.

Keywords

openprofiling

FAQs

Package last updated on 05 Jul 2020

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