如何在Shipit.js上设置密码

时间:2019-05-19 21:16:40

标签: node.js sudo shipitjs

我对shipit.js的部署如下所示

// shipitfile.js
module.exports = shipit => {
  // Load shipit-deploy tasks
  require('shipit-deploy')(shipit)
  const backend_folder = 'backend';


  shipit.initConfig({
    default: {
      deployTo: '/var/www/app/',
      repositoryUrl: 'git@github.com:user/app.git',
    },
    staging: {
      servers: 'deploy@ip.ip.ip.ip',
    },
  })

  shipit.blTask('npm:install', async () => {
    await shipit.remote(`cd ${shipit.releasePath}/${backend_folder}/ && npm install --production`)
  })

  shipit.blTask('server:start', async () => {
    const be_command = 'NODE_ENV=production forever start build/server.js'
    await shipit.remote(`cd ${shipit.config.deployTo}/current/`
                        + `${backend_folder}/ && ${be_command}`)
  })

  shipit.blTask('server:restart', async () => {
    const command = 'forever restartall'
    await shipit.remote(`cd ${shipit.config.deployTo} && ${command}`)
  })

  shipit.on('updated', () => {
    shipit.start('npm:install')
  })

  shipit.on('published', () => {
    shipit.start('server:restart')
  })
}

尝试从github克隆时,shipit失败,因为deploy需要使用sudo创建文件夹。我该如何提供Shipit deploy的密码,以便它可以sudo并创建文件夹?

谢谢。

0 个答案:

没有答案