0

I've got an instance of Apostrophe-CMS which I'm trying to deploy to production at the moment. Running sudo npm start works fine and the application boots. However, when I try to have the pm2 daemon run it I'm getting a symlink error:

Error: EEXIST: file already exists, symlink '/var/sites/hackday-2016-microsite/node_modules/apostrophe/lib/modules/apostrophe-assets/public' -> '/var/sites/hackday-2016-microsite/public/modules/apostrophe-assets' hackday2016-28 at Error (native) hackday2016-28 at Object.fs.symlinkSync (fs.js:1048:18) hackday2016-28 at Object.self.linkAssetFolderOnUnix (/var/sites/hackday-2016-microsite/node_modules/apostrophe/lib/modules/apostrophe-assets/index.js:447:10) hackday2016-28 at Object.self.linkAssetFolder (/var/sites/hackday-2016-microsite/node_modules/apostrophe/lib/modules/apostrophe-assets/index.js:424:14) hackday2016-28 at /var/sites/hackday-2016-microsite/node_modules/apostrophe/lib/modules/apostrophe-assets/index.js:402:14 hackday2016-28 at /var/sites/hackday-2016-microsite/node_modules/lodash/index.js:3073:15 hackday2016-28 at baseForOwn (/var/sites/hackday-2016-microsite/node_modules/lodash/index.js:2046:14) hackday2016-28 at /var/sites/hackday-2016-microsite/node_modules/lodash/index.js:3043:18 hackday2016-28 at Function.<anonymous> (/var/sites/hackday-2016-microsite/node_modules/lodash/index.js:3346:13) hackday2016-28 at self.symlinkModules (/var/sites/hackday-2016-microsite/node_modules/apostrophe/lib/modules/apostrophe-assets/index.js:398:9) hackday2016-28 at /var/sites/hackday-2016-microsite/node_modules/async/lib/async.js:718:13 hackday2016-28 at iterate (/var/sites/hackday-2016-microsite/node_modules/async/lib/async.js:262:13) hackday2016-28 at async.forEachOfSeries.async.eachOfSeries (/var/sites/hackday-2016-microsite/node_modules/async/lib/async.js:281:9) hackday2016-28 at _parallel (/var/sites/hackday-2016-microsite/node_modules/async/lib/async.js:717:9) hackday2016-28 at Object.async.series (/var/sites/hackday-2016-microsite/node_modules/async/lib/async.js:739:9) hackday2016-28 at Object.self.afterInit (/var/sites/hackday-2016-microsite/node_modules/apostrophe/lib/modules/apostrophe-assets/index.js:349:20)

  • Hmm, a clarifying question? Are you using pm2 to launch multiple instances simultaneously and load-balance? That's not bad, but it's relevant to what I would suggest next. – Tom Boutell Nov 01 '16 at 19:24
  • PM2 is managing multiple node applications on that single server, but only one instance of the apostrophe application. – jerikojones Nov 02 '16 at 10:32
  • This could be a permissions issue, if the user running apostrophe doesn't have permissions to do as it sees fit in public/modules. It could also be that pm2 is configured to run more than one process for load balancing, which is what I was asking about earlier. Recommend running "node app apostrophe:generation" after deploy and before you start up server processes. This avoids a race condition. – Tom Boutell Nov 04 '16 at 18:00

1 Answers1

0

I am pretty new to ApostropheCMS too and have been playing around for sometime. It looks like you have a symlink created to link the apostrophe-assets folder to a public folder? I don't understand the need to do that. AposCMS automatically picks up all the assets in the

node_modules/apostrophe/lib/modules/apostrophe-assets/public and

/var/sites/hackday-2016-microsite/public/modules/apostrophe-assets folders.

All you have to do is make sure that you are declaring the assets that you are adding for your project under /var/sites/hackday-2016-microsite/lib/modules/apostrophe-pages/index.js

here is the code that I have under my file

    module.exports = {
        park: [{
            slug: '/search',
            type: 'apostrophe-search',
            label: 'Search',
            published: true
        }],
        types: [{
                name: 'default',
                label: 'Default'
            },
            {
                name: 'home',
                label: 'Home'
            },
            {
                name: 'apostrophe-blog-page',
                label: 'Blog'
            }
        ],

    //construct is one of the nunjucks functions that gets called when app.js starts
    construct: function(self, options) {

        //push assets to for use in front end - e.g. lib/modules/apostrophe-pages/public/js/site.js

        self.pushAsset('script', 'site', { scene: 'always' });
        self.pushAsset('script', 'jquery.easing', { scene: 'always' });
        self.pushAsset('script', 'jquery.scrollTo', { scene: 'always' });
        self.pushAsset('script', 'bootstrap', { scene: 'always' });
        self.pushAsset('script', 'jquery.easing', { scene: 'always' });
        self.pushAsset('script', 'jquery.matchHeight', { scene: 'always' });
        self.pushAsset('script', 'jquery.easy-autocomplete', { scene: 'always' });
    }
};

And for adding the css files, you can do that under

/var/sites/hackday-2016-microsite/public/modules/apostrophe-assets/public/css/site.less my code in the file is:

@import 'utilities/_index.less';
@import 'typography/_index.less';
@import 'layout/_index.less';
@import 'templates/_index.less';
@import 'components/_index.less';
@import 'global/_index.less';
@import 'components/easy-autocomplete.less';
@import 'components/easy-autocomplete.themes.less';
// this is the place were we are adding the css syles so that they get automatically compiled
// and are minified and send out as one file
@import 'custom/bootstrap.less';
@import 'custom/font-awesome.less';
@import 'custom/jquery.autocomplete.less';
@import 'custom/simple-sidebar.less';
@import 'custom/style.less';

.apos-slideshow-item
{
  h4
  {
    display: none;
  }
}
Parik Tiwari
  • 1,525
  • 1
  • 12
  • 19