Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run command in before_migrate.rb as user with sudo privileges not working #394

Open
mattymess opened this issue Sep 26, 2016 · 0 comments
Open

Comments

@mattymess
Copy link

mattymess commented Sep 26, 2016

In my Rails app, I'm trying to run a gulp task during deployment, which adds a css file to a directory inside the public directory. In the deployment log, I see that the task runs successfully, but when I SSH into the server, I don't see the file.

[2016-09-24T01:35:02+00:00] INFO: Processing execute[create critical css] action run (/srv/www/toaster/releases/20160924013146/deploy/before_migrate.rb line 43)
[2016-09-24T01:35:03+00:00] INFO: execute[create critical css] ran successfully

While I'm connected to the server via SSH and change my user to the deploy user with sudo su deploy and then run the gulp task, the file gets create.

What am I doing wrong?

The line in before_migrate looks like this...

execute 'create critical css' do
  user 'deploy'
  cwd release_path
  command 'gulp criticalCss'
end

The task in my gulpfile looks like this...

gulp.task('criticalCss', function() {
  glob('./public/assets/theme_templates/v3/application-*.css', function(err, matches) {
    var full_css = matches[0]

    penthouse({
      url : 'http://performance-site.s2.fanbread.com/blogs/performance-benchmark',
      css : full_css,
      width: 375,
      height: 667
    }, function(err, criticalCss) {
      console.log(err)
      fs.writeFile('./public/assets/theme_templates/v3/posts_show.css', criticalCss); // Write the contents to a jekyll include
    });
  });
});

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant