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

Unable to Update Ghost to v0.8.0 on production server #7084

Closed
prashantsani opened this issue Jul 11, 2016 · 15 comments

Comments

Projects
None yet
2 participants
@prashantsani
Copy link

commented Jul 11, 2016

Hello,
I have a live blog and I'm unable to update my ghost blog as per the docs.

I tried several combinations of following :

  1. deleting entire core, node_modules and index.js file and replacing it with new ones
  2. using npm cache clean
  3. changing and updating to root level and using the commands as a root user.
  4. changing node version.

But none of them work.

While using 0.12.0, I get following error while installing node

> npm install semver && node -e "require('./core/server/utils/startup-check.js').nodeVersion()"

semver@5.1.0 node_modules/semver

> jsonpath@0.2.2 postinstall /var/www/ghost/node_modules/jsonpath
> node lib/aesprim.js > generated/aesprim-browser.js

Killed

What does Killed mean?

This is what is shown when I type npm start --production

>ghost@0.8.0 start /var/www/ghost
> node index

module.js:338
    throw err;
          ^
Error: Cannot find module 'xmlbuilder'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/var/www/ghost/node_modules/nodemailer/node_modules/aws-sdk/lib/xml/builder.js:2:15)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/var/www/ghost/node_modules/nodemailer/node_modules/aws-sdk/lib/core.js:42:14)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)

npm ERR! Linux 3.13.0-57-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start" "--production"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! code ELIFECYCLE
npm ERR! ghost@0.8.0 start: `node index`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ghost@0.8.0 start script 'node index'.
npm ERR! This is most likely a problem with the ghost package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node index
npm ERR! You can get their info via:
npm ERR!     npm owner ls ghost
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/ghost/npm-debug.log

And these are contents of /var/www/ghost/npm-debug.log


0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'start',
1 verbose cli   '--production' ]
2 info using npm@1.2.14
3 info using node@v0.10.0
4 verbose read json /var/www/package.json
5 error Error: ENOENT, open '/var/www/package.json'
6 error If you need help, you may report this log at:
6 error     <http://github.com/isaacs/npm/issues>
6 error or email it to:
6 error     <npm-@googlegroups.com>
7 error System Linux 3.13.0-57-generic
8 error command "/usr/local/bin/node" "/usr/local/bin/npm" "start" "--production"
9 error cwd /var/www
10 error node -v v0.10.0
11 error npm -v 1.2.14
12 error path /var/www/package.json
13 error code ENOENT
14 error errno 34
15 verbose exit [ 34, true ]

Update: I get the same issue while installing 0.9.0-beta.2

> ghost@0.9.0-beta.2 preinstall /var/www/ghost
> npm install semver && node -e "require('./core/server/utils/startup-check.js').nodeVersion()"

semver@5.1.0 node_modules/semver
Killed

Thanks

@prashantsani

This comment has been minimized.

Copy link
Author

commented Jul 11, 2016

The Solution was given over at slack community by @acburdine

So, the issue (Killed ) occurs because NPM might use a lot of resources/RAM while installing packages.
We can use couple of solutions :

  1. Increase RAM/Resources of our VPS/Droplets/Servers
  2. Use solution described here - https://www.digitalocean.com/community/questions/npm-gets-killed-no-matter-what and here -https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

For me, I tried doing something very simple before trying out 2 options above

  1. I rebooted my DigitalOcean's Droplet. One can do so by typing sudo rebooton a Linux system like Ubuntu.
  2. After reboot, I did a fresh install of ghost on a separate directory
  3. I copied older images, themes, config.js and data.json files from my previous folder
  4. I restarted Ghost service.

It worked!
I would suggest using my solution before upgrading/or adding swap.

@kevinSuttle

This comment has been minimized.

Copy link

commented Jul 22, 2016

Thanks @prashantsani for documenting this. I had the exact same issue.

The only thing I'd add was at the very beginning, I got a strange message—the one reported here.

$ npm install --production
npm WARN cannot run in wd ghost@0.8.0 npm install semver && node -e "require('./core/server/utils/startup-check.js').nodeVersion()" (wd=/var/www/ghost)
@kevinSuttle

This comment has been minimized.

Copy link

commented Jul 22, 2016

None of these things fixed it for me, however...

@prashantsani

This comment has been minimized.

Copy link
Author

commented Jul 22, 2016

@kevinSuttle try contacting them over slack

https://ghost.org/slack/

And if you find a solution, then add here.

@prashantsani

This comment has been minimized.

Copy link
Author

commented Jul 22, 2016

@kevinSuttle Do you have a back of your blog? If so you can make a install on a new directory and copy images & themes to new directory. Don't forget to update your config.js file

@kevinSuttle

This comment has been minimized.

Copy link

commented Jul 22, 2016

I changed permissions on everything, rebooted the droplet: nothing.

All of the following were ran with and without sudo:

chown -R root:root core
chown -R ghost:ghost core
chown -R root:root content
chown -R ghost:ghost content
chown -R root:root *
chown -R ghost:ghost *
npm cache clean
npm install --production --unsafe-perm
rm -rf node_modules

@kevinSuttle

This comment has been minimized.

Copy link

commented Jul 22, 2016

@prashantsani That link doesn't work for me. I can't figure out how to sign in to the Ghost Slack or where. Nothing I enter is correct.

Edit: seems this isn't just me. #7109 (comment)

@prashantsani

This comment has been minimized.

Copy link
Author

commented Jul 22, 2016

Register yourselfon the ghost slack link mentioned above.
Then use slack to communicate with other ghost members.

Which node version you are using?
try using node 0.10.0

Also, you don't need to chown any director to root user. Root user has permissions for most of the directories.

@kevinSuttle

This comment has been minimized.

Copy link

commented Jul 22, 2016

$ node -v
v4.2.4

That's the latest version provided by apt-get on my system as far as I can tell.

@kevinSuttle

This comment has been minimized.

Copy link

commented Jul 22, 2016

I used nvm to install 0.10.46 to no avail. Same exact issue with npm.

@kevinSuttle

This comment has been minimized.

Copy link

commented Jul 22, 2016

Hm. Now I'm in situation where I got it install to happen without errors, and sudo service ghost start/restart says it works, but the blog will not run unless I manually type in npm start --production and leave the terminal open—no logging out, no CTRL-C, no closing the terminal tab, etc.

It results in this in the browser:

502 Bad Gateway

nginx/1.9.9

I try to restart nginx, which works, but notice that weird double nginx... P

root@ghost-ubuntu-512mb-nyc2-01:~# sudo service nginx restart
 * Restarting nginx nginx
$ sudo service ghost restart
ghost stop/waiting
ghost start/running, process 7282

$ npm start --production

> ghost@0.8.0 start /var/www/ghost
> node index

Migrations: Up-to-date at version 005
Ghost is running in production...
Your blog is now available on http://kevinsuttle.com
Ctrl+C to shut down

I saw the traffic logging in the terminal after I logged into the Ghost admin UI in the browser. Then I saw this error in the terminal:

127.0.0.1 - - [22/Jul/2016:20:26:58 +0000] "GET /ghost/vendor.min.js?v=bc8b0446e1 HTTP/1.0" 200 - "https://kevinsuttle.com/ghost/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36"

ERROR: Invalid refresh token.

 Error
    at Error.NoPermissionError (/var/www/ghost/core/server/errors/no-permission-error.js:6:18)
    at then (/var/www/ghost/core/server/middleware/oauth.js:14:25)
    at tryCatcher (/var/www/ghost/node_modules/bookshelf/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/var/www/ghost/node_modules/bookshelf/node_modules/bluebird/js/main/promise.js:507:31)
    at Promise._settlePromiseAt (/var/www/ghost/node_modules/bookshelf/node_modules/bluebird/js/main/promise.js:581:18)
    at Async._drainQueue (/var/www/ghost/node_modules/bookshelf/node_modules/bluebird/js/main/async.js:128:12)
    at Async._drainQueues (/var/www/ghost/node_modules/bookshelf/node_modules/bluebird/js/main/async.js:133:10)
    at Async.drainQueues (/var/www/ghost/node_modules/bookshelf/node_modules/bluebird/js/main/async.js:15:14)
    at process._tickDomainCallback (node.js:502:13)
@prashantsani

This comment has been minimized.

Copy link
Author

commented Jul 22, 2016

For running the process continuously use pm2/forever.
http://support.ghost.org/deploying-ghost/

I think it's a config error. You have to close the ghost service and then copy the old config.js file or edit the new one.

@kevinSuttle

This comment has been minimized.

Copy link

commented Jul 22, 2016

I had this running without pm2/forever before.

I noticed that the ghost service doesn't appear anymore here:

$ sudo service --status-all
 [ + ]  acpid
 [ + ]  apparmor
 [ ? ]  apport
 [ + ]  atd
 [ ? ]  console-setup
 [ + ]  cron
 [ - ]  dbus
 [ ? ]  dns-clean
 [ + ]  friendly-recovery
 [ - ]  grub-common
 [ ? ]  irqbalance
 [ ? ]  killprocs
 [ ? ]  kmod
 [ ? ]  networking
 [ + ]  nginx
 [ + ]  nginx-debug
 [ ? ]  ondemand
 [ - ]  openbsd-inetd
 [ + ]  postfix
 [ ? ]  pppd-dns
 [ + ]  procps
 [ ? ]  rc.digitalocean
 [ ? ]  rc.local
 [ + ]  resolvconf
 [ - ]  rsync
 [ + ]  rsyslog
 [ ? ]  screen-cleanup
 [ ? ]  sendsigs
 [ + ]  ssh
 [ - ]  sudo
 [ + ]  udev
 [ ? ]  umountfs
 [ ? ]  umountnfs.sh
 [ ? ]  umountroot
 [ - ]  unattended-upgrades
 [ - ]  urandom

But again, running sudo service ghost start | restart | stop works and reports as an other service does.

The /etc/init/ghost.conf file looks like this:

description "Ghost: Just a blogging platform"

start on (local-filesystems and net-device-up IFACE=eth0)
stop on runlevel [!12345]

# If the process quits unexpectadly trigger a respawn
respawn

setuid ghost
setgid ghost
env NODE_ENV=production
chdir /var/www/ghost

exec /usr/local/bin/npm start --production

pre-stop exec /usr/local/bin/npm stop --production
@kevinSuttle

This comment has been minimized.

Copy link

commented Jul 22, 2016

I had to install forever, and run this in the root directory. This is so odd, as I have never had to run it before, and nothing I included in etc/init/ghost.conf did anything.

NODE_ENV=production forever start index.js

@prashantsani

This comment has been minimized.

Copy link
Author

commented Sep 23, 2016

Had A similar issue while reinstalling Ghost on the server.
Realised that config.js was corrupt. A simple js lint on config.js would show the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.