Skip to content
This repository was archived by the owner on Jun 20, 2025. It is now read-only.

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

Description

@mattymess

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions