dasuchin / grunt-ssh-deploy

Grunt SSH Deployment
MIT License
66 stars 45 forks source link

Symlink at a different level than releases #30

Closed julien731 closed 9 years ago

julien731 commented 9 years ago

Is there any way to have the symlinked folder and the releases folder at a different level on the server? And if not, is there any way to get the name of the folder that's just been created for the new release so that I can manually create a symlink after deployment?

siamkreative commented 9 years ago

The idea here is to create a structure like that:

|___ wp-content
|______ releases
|______ themes
|_________ symlink_name

We love SSH deploy, but the issue while trying to deploy a WordPress theme is that WordPress will actually look into the /releases/ folder if it's located inside the theme folder. As a result, WordPress will see multiple versions of the same theme (the different releases).

dasuchin commented 9 years ago

Shouldn't you be able to set deploy_path to be under wp-content, and then current_symlink to be under the theme directory?

julien731 commented 9 years ago

That's what I tried, but it seems that the symlink created only points to a same level directory. With this config, releases is correctly created in wp-content, the symlink is correctly created in the themes directory, but the symlink target is at the same level, hence looking for releases inside themes when it should be pointing one level up.

dasuchin commented 9 years ago

Can you post your config?

This is the command that creates the symlink, you may want to try doing this manually on your server and see the result: 'cd ' + options.deploy_path + ' && ln -s releases/' + timestamp + ' ' + options.current_symlink;

Edit: may need to change that command to have the full deploy_path. Anyone else having this issue?

siamkreative commented 9 years ago

Our current config:

{
    "production": {
        "host": "XXXXX",
        "username": "XXXXX",
        "password": "XXXXX",
        "port": "22",
        "current_symlink": "moneo",
        "zip_deploy": true,
        "deploy_path": "/srv/users/serverpilot/apps/wordpress/public/wp-content/themes"
    }
}

What we also tried to move the /releases/ folder outside the /themes/ directory. It partially worked: the releases folder is located in /wp-content/ but the symlink does not work.

{
    "production": {
        "host": "XXXXX",
        "username": "XXXXX",
        "password": "XXXXX",
        "port": "22",
        "current_symlink": "themes/moneo",
        "zip_deploy": true,
        "deploy_path": "/srv/users/serverpilot/apps/wordpress/public/wp-content"
    }
}
dasuchin commented 9 years ago

I would suggest editing your local copy of the code and changing the cd command to see if that fixes it.

siamkreative commented 9 years ago

Hey @dasuchin, could you please point me in the right direction? I'm not familiar with NodeJS...

Would you consider updating your plugin to allow this use case?

MarkRabey commented 9 years ago

@dasuchin I'm having a similar issue. Would love to see this available. As I am somewhat familiar with Node.js, I can work on a fix and submit a PR if you're cool with that.

dasuchin commented 9 years ago

@MarkRabey go ahead.

siamkreative commented 9 years ago

Thanks @MarkRabey, can't wait to test it :)

siamkreative commented 9 years ago

Any update on this @MarkRabey ?

MarkRabey commented 9 years ago

Sorry for the delay, got busy.

What I did (at least to work for me) was make the symlink use an absolute path. So, I edited line 182 to read:

var set_symlink = 'cd ' + options.deploy_path + ' && ln -s ' + options.deploy_path + '/releases/' + timestamp + ' ' + options.deploy_path + '/' + options.current_symlink;

This actually means that the first part of that command ('cd ' + options.deploy_path + ' &&) is kind of irrelevant.

I honestly only checked this with my use-case, but if it's an adequate solution, I will submit a pull-request.

Sorry again for the delay.

dasuchin commented 9 years ago

I merged this in.

MarkRabey commented 9 years ago

Great! Thanks :)