ecosystem.config.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // PM2 生态系统配置文件
  2. // 用于管理Delta中性交易策略的进程
  3. module.exports = {
  4. apps: [
  5. {
  6. name: 'delta-neutral-trading',
  7. script: 'yarn',
  8. args: 'trade',
  9. interpreter: 'none',
  10. // 实例配置
  11. instances: 1,
  12. exec_mode: 'fork',
  13. // 自动重启配置
  14. autorestart: true, // 自动重启
  15. watch: false, // 不监视文件变化
  16. max_restarts: 100, // 最大重启次数
  17. min_uptime: '10s', // 最小运行时间
  18. restart_delay: 5000, // 重启延迟(毫秒)
  19. // 内存限制
  20. max_memory_restart: '2G', // 内存超过2G时重启
  21. // 环境变量
  22. env: {
  23. NODE_ENV: 'production',
  24. NODE_OPTIONS: '--max-old-space-size=2048'
  25. },
  26. // 日志配置
  27. log_date_format: 'YYYY-MM-DD HH:mm:ss',
  28. error_file: 'logs/pm2-error.log',
  29. out_file: 'logs/pm2-out.log',
  30. merge_logs: true,
  31. time: true,
  32. // 进程信号处理
  33. kill_timeout: 10000, // 关闭超时(毫秒)
  34. shutdown_with_message: true,
  35. // 监控配置
  36. monitoring: true,
  37. // 崩溃处理
  38. exp_backoff_restart_delay: 100, // 指数退避重启延迟
  39. },
  40. {
  41. name: 'position-monitor',
  42. script: 'yarn',
  43. args: 'positions',
  44. interpreter: 'none',
  45. // 每隔5分钟检查一次仓位
  46. cron_restart: '*/5 * * * *',
  47. autorestart: false,
  48. // 日志配置
  49. log_date_format: 'YYYY-MM-DD HH:mm:ss',
  50. error_file: 'logs/position-monitor-error.log',
  51. out_file: 'logs/position-monitor-out.log',
  52. env: {
  53. NODE_ENV: 'production'
  54. }
  55. },
  56. {
  57. name: 'health-check',
  58. script: './scripts/health-check.js',
  59. // 每隔1分钟检查系统健康状态
  60. cron_restart: '* * * * *',
  61. autorestart: false,
  62. // 日志配置
  63. log_date_format: 'YYYY-MM-DD HH:mm:ss',
  64. error_file: 'logs/health-check-error.log',
  65. out_file: 'logs/health-check-out.log',
  66. env: {
  67. NODE_ENV: 'production'
  68. }
  69. }
  70. ],
  71. deploy: {
  72. production: {
  73. user: 'node',
  74. host: 'localhost',
  75. ref: 'origin/master',
  76. repo: 'http://developer.mtdao.io/Malone/pacifica.git',
  77. path: '/var/www/pacifica',
  78. 'post-deploy': 'npm install && pm2 reload ecosystem.config.js --env production'
  79. }
  80. }
  81. };