Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndreiTelteu/533eea4b3919ee2e5258ce6a65d3fe94 to your computer and use it in GitHub Desktop.
Save AndreiTelteu/533eea4b3919ee2e5258ce6a65d3fe94 to your computer and use it in GitHub Desktop.

If you use a ecosystem file, add the following lines to your app:

      interpreter: '/home/forge/.fnm/fnm',
      interpreter_args: 'exec --using=14 node',

14 is the node version. You can be more specific like --using=12.22.4

Example configuration:

module.exports = {
  apps : [
    {
      name: "site",
      script: "./index.js",
      watch: false,
      interpreter: '/home/ubuntu/.fnm/fnm',
      interpreter_args: 'exec --using=14 node',
      env: {
        "NODE_ENV": "production",
      },
    },
  ]
}

If you have problems when trying to start global installed modules (like soketi) after a server reboot, try this:

module.exports = {
    apps: [
        {
            name: "soketi",
            script: "soketi", // this does not matter anymore but it's required
            watch: false,
            interpreter: "/usr/bin/bash",
            interpreter_args: "-c '/home/ubuntu/.fnm/fnm exec --using=14 soketi start --config=/absolute/path/to/soketi/config.json'",
            autorestart: true,
        },
    ],
};

bash -c 'script' - This fixes the problem by loading the bash profile before executing the script.

Important! Always check if the application starts correctly after a server reboot. Fnm changes the path to the node executable after a reboot and your app will not start after reboot.

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