pm2 and jailkit configuration

Discussion in 'Installation/Configuration' started by brody182, Jan 11, 2020.

  1. brody182

    brody182 Member

    Hi!
    I'm trying to run apps with pm2 in a jail environment using jailkit. I think I have to configure a path somewhere but I'm lost with it. My config files:


    [Unit]
    Description=PM2 process manager
    Documentation=https://pm2.keymetrics.io/
    After=network.target

    [Service]
    Type=forking
    User=<USER>
    LimitNOFILE=infinity
    LimitNPROC=infinity
    LimitCORE=infinity
    Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
    Environment=PM2_HOME=/home/jail/home/<USER>/.pm2
    PIDFile=/home/jail/home/<USER>/.pm2/pm2.pid
    Restart=on-failure

    ExecStart=/usr/lib/node_modules/pm2/bin/pm2 resurrect
    ExecReload=/usr/lib/node_modules/pm2/bin/pm2 reload all
    ExecStop=/usr/lib/node_modules/pm2/bin/pm2 kill

    [Install]
    WantedBy=multi-user.target
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Youi do not write much about what is not working.
    So I just guess some command is not available in the jail? Add the necessary commands and their run time libraries to the jail. Jailkit has commands for this.
    https://www.howtoforge.com/tutorial/debian-9-jail-jailkit/
    More info can be found with Internet Search Engines or Oliver Sessings Jailkit documentation.
     
  3. brody182

    brody182 Member

    What paths do I put in here?

    nvironment=PM2_HOME=/home/jail/home/<USER>/.pm2
    PIDFile=/home/jail/home/<USER>/.pm2/pm2.pid
     
  4. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Is that configuration file in a place where the application does find it?
    Since the application is run in a jail, you have to use paths that are valid inside that jail. If this is ISPConfig and jailed user, at least on my host the home directory is not /home/jail/home/<user>, but /home/<user>. Check what directories you have by logging in as that jailed user with the usual command line commands.
     
  5. brody182

    brody182 Member

    you are correct my jail directory is /home/<user>, however, I don't want to target a specific user, I want it to apply to all users

    the config file is ( /etc/jailkit/jk_init.ini)
     
  6. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    That looks like jailkit configuration file. Is that related to your problem, whatever it is?
    Each jailed user has his/her own jail, so I can not see how you could have paths inside jail apply to all users.
    Now you should know which paths you need to set. Since I have no idea what is not working in that PM2 setup, I can help no more.
     

Share This Page