第一次尝试将SailsJS应用程序部署到Heroku并与之斗争。
我的应用在本地正常运行(MacOS X)。
if ($token) {
$client->setAccessToken($token);
} else {
$client->refreshToken($token['refresh_token']);
}
// Check to ensure that the access token was successfully acquired.
// Check to ensure that the access token was successfully acquired.
if ($client->getAccessToken()) {
try {
// Call the channels.list method to retrieve information about the
// currently authenticated user's channel.
$channelsResponse = $youtube->channels->listChannels('contentDetails', array(
'mine' => 'true',
));
$htmlBody = '';
foreach ($channelsResponse['items'] as $channel) {
// Extract the unique playlist ID that identifies the list of videos
// uploaded to the channel, and then call the playlistItems.list method
// to retrieve that list.
$uploadsListId = $channel['contentDetails']['relatedPlaylists']['uploads'];
$playlistItemsResponse = $youtube->playlistItems->listPlaylistItems('snippet', array(
'playlistId' => $uploadsListId,
'maxResults' => 50
));
foreach ($playlistItemsResponse['items'] as $playlistItem)
{
$videoTitle[$count]=$playlistItem['snippet']['title'];
$videoDescription[$count]=$playlistItem['snippet']['description'];
$count++;
}
}
} catch (Google_Service_Exception $e) {
$htmlBody .= sprintf('<p>A service error occurred: <code>%s</code></p>',
htmlspecialchars($e->getMessage()));
} catch (Google_Exception $e) {
$htmlBody .= sprintf('<p>An client error occurred: <code>%s</code></p>',
htmlspecialchars($e->getMessage()));
}
}
$ sails --version
0.12.3
heroku logs -a myapp-webrtc
2016-06-02T16:52:45.297076+00:00 app[web.1]:
2016-06-02T16:52:45.297142+00:00 app[web.1]: *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
2016-06-02T16:52:45.297191+00:00 app[web.1]:
2016-06-02T16:52:45.297277+00:00 app[web.1]: *-> Or maybe you don't have permissions to access the `.tmp` directory?
2016-06-02T16:52:45.297383+00:00 app[web.1]: e.g., `/app/.tmp` ?
2016-06-02T16:52:45.297434+00:00 app[web.1]:
2016-06-02T16:52:45.297485+00:00 app[web.1]: If you think this might be the case, try running:
2016-06-02T16:52:45.297607+00:00 app[web.1]: sudo chown -R 58669 /app/.tmp
2016-06-02T16:52:45.297675+00:00 app[web.1]:
2016-06-02T16:53:01.611997+00:00 app[web.1]: Error: The hook `grunt` is taking too long to load.
2016-06-02T16:53:01.612013+00:00 app[web.1]: at Timer.listOnTimeout (timers.js:198:5) { [Error: The hook `grunt` is taking too long to load.
2016-06-02T16:53:01.612012+00:00 app[web.1]: at tryOnTimeout (timers.js:224:11)
2016-06-02T16:53:01.612010+00:00 app[web.1]: Make sure it is triggering its `initialize()` callback, or else set `sails.config.grunt._hookTimeout to a higher value (currently 20000)
2016-06-02T16:53:01.612011+00:00 app[web.1]: at Timeout.tooLong [as _onTimeout] (/app/node_modules/sails/lib/app/private/loadHooks.js:85:21)
2016-06-02T16:53:01.612014+00:00 app[web.1]: Make sure it is triggering its `initialize()` callback, or else set `sails.config.grunt._hookTimeout to a higher value (currently 20000)] code: 'E_HOOK_TIMEOUT' }
2016-06-02T16:53:02.849738+00:00 heroku[web.1]: Process exited with status 0
2016-06-02T16:53:02.872998+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-02T16:53:06.350353+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=myapp-webrtc.herokuapp.com request_id=2d8d592c-b091-4b87-b347-378498e5716c fwd="93.201.9.157" dyno= connect= service= status=503 bytes=
2016-06-02T16:53:06.921700+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=myapp-webrtc.herokuapp.com request_id=df38991d-ef49-4563-a119-034aa717644a fwd="93.201.9.157" dyno= connect= service= status=503 bytes=
2016-06-02T17:15:14.982813+00:00 heroku[web.1]: State changed from crashed to starting
2016-06-02T17:15:24.437298+00:00 heroku[web.1]: Starting process with command `npm start`
2016-06-02T17:15:28.109941+00:00 app[web.1]:
2016-06-02T17:15:28.109962+00:00 app[web.1]: > myapp-sails-website@0.0.0 start /app
2016-06-02T17:15:28.109966+00:00 app[web.1]:
2016-06-02T17:15:28.109965+00:00 app[web.1]: > node app.js
2016-06-02T17:15:32.969953+00:00 app[web.1]: designed for a production environment, as it will leak
2016-06-02T17:15:32.969938+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2016-06-02T17:15:32.969954+00:00 app[web.1]: memory, and will not scale past a single process.
2016-06-02T17:15:39.385511+00:00 app[web.1]: ------------------------------------------------------------------------
2016-06-02T17:15:39.385517+00:00 app[web.1]: [Function: _cleanupCallback] ]
2016-06-02T17:15:39.385487+00:00 app[web.1]:
2016-06-02T17:15:39.392709+00:00 app[web.1]:
2016-06-02T17:15:39.385518+00:00 app[web.1]: Running "bower:install" (bower) task
2016-06-02T17:15:39.385518+00:00 app[web.1]: >> Cleaned target dir /app/assets/vendor
2016-06-02T17:15:39.385519+00:00 app[web.1]: ------------------------------------------------------------------------
2016-06-02T17:15:39.385516+00:00 app[web.1]: Fatal error: Path must be a string. Received [ '/tmp/0077235362b904e0706919379d9abb40/bower/fontawesome-26-IEN3KJ',
2016-06-02T17:15:39.394064+00:00 app[web.1]: *-> Are "grunt" and related grunt task modules installed locally? Run `npm install` if you're not sure.
2016-06-02T17:15:39.393890+00:00 app[web.1]: Troubleshooting tips:
2016-06-02T17:15:39.392884+00:00 app[web.1]: Looks like a Grunt error occurred--
2016-06-02T17:15:39.394010+00:00 app[web.1]:
2016-06-02T17:15:39.394278+00:00 app[web.1]: *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
2016-06-02T17:15:39.392993+00:00 app[web.1]: Please fix it, then **restart Sails** to continue running tasks (e.g. watching for changes in assets)
2016-06-02T17:15:39.393169+00:00 app[web.1]:
2016-06-02T17:15:39.393066+00:00 app[web.1]: Or if you're stuck, check out the troubleshooting tips below.
2016-06-02T17:15:39.394178+00:00 app[web.1]:
2016-06-02T17:15:39.394816+00:00 app[web.1]: sudo chown -R 51606 /app/.tmp
2016-06-02T17:15:39.394625+00:00 app[web.1]:
2016-06-02T17:15:39.394892+00:00 app[web.1]:
2016-06-02T17:15:39.394374+00:00 app[web.1]: *-> Or maybe you don't have permissions to access the `.tmp` directory?
2016-06-02T17:15:39.394532+00:00 app[web.1]: e.g., `/app/.tmp` ?
2016-06-02T17:15:39.394328+00:00 app[web.1]:
2016-06-02T17:15:39.394676+00:00 app[web.1]: If you think this might be the case, try running:
2016-06-02T17:15:52.228153+00:00 app[web.1]: Error: The hook `grunt` is taking too long to load.
2016-06-02T17:15:52.228162+00:00 app[web.1]: Make sure it is triggering its `initialize()` callback, or else set `sails.config.grunt._hookTimeout to a higher value (currently 20000)
2016-06-02T17:15:52.228164+00:00 app[web.1]: at Timeout.tooLong [as _onTimeout] (/app/node_modules/sails/lib/app/private/loadHooks.js:85:21)
2016-06-02T17:15:52.228165+00:00 app[web.1]: at tryOnTimeout (timers.js:224:11)
2016-06-02T17:15:52.228165+00:00 app[web.1]: at Timer.listOnTimeout (timers.js:198:5) { [Error: The hook `grunt` is taking too long to load.
2016-06-02T17:15:52.228167+00:00 app[web.1]: Make sure it is triggering its `initialize()` callback, or else set `sails.config.grunt._hookTimeout to a higher value (currently 20000)] code: 'E_HOOK_TIMEOUT' }
2016-06-02T17:15:53.669743+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-02T17:15:53.655028+00:00 heroku[web.1]: Process exited with status 0
2016-06-02T18:06:31.272886+00:00 heroku[web.1]: State changed from crashed to starting
2016-06-02T18:06:36.225210+00:00 heroku[web.1]: Starting process with command `npm start`
2016-06-02T18:06:38.532682+00:00 app[web.1]: > myapp-sails-website@0.0.0 start /app
2016-06-02T18:06:38.532687+00:00 app[web.1]: > node app.js
2016-06-02T18:06:38.532667+00:00 app[web.1]:
2016-06-02T18:06:38.532688+00:00 app[web.1]:
2016-06-02T18:06:40.055713+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2016-06-02T18:06:40.055780+00:00 app[web.1]: memory, and will not scale past a single process.
2016-06-02T18:06:40.055777+00:00 app[web.1]: designed for a production environment, as it will leak
2016-06-02T18:06:43.891199+00:00 app[web.1]: ------------------------------------------------------------------------
2016-06-02T18:06:43.891203+00:00 app[web.1]: [Function: _cleanupCallback] ]
2016-06-02T18:06:43.891204+00:00 app[web.1]: >> Cleaned target dir /app/assets/vendor
2016-06-02T18:06:43.891202+00:00 app[web.1]: Fatal error: Path must be a string. Received [ '/tmp/9f58527d2d49adf07e59162a077b871c/bower/bootstrap-26-nvHWyj',
2016-06-02T18:06:43.891205+00:00 app[web.1]: ------------------------------------------------------------------------
2016-06-02T18:06:43.891203+00:00 app[web.1]: Running "bower:install" (bower) task
2016-06-02T18:06:43.891391+00:00 app[web.1]: Looks like a Grunt error occurred--
2016-06-02T18:06:43.891393+00:00 app[web.1]: Please fix it, then **restart Sails** to continue running tasks (e.g. watching for changes in assets)
2016-06-02T18:06:43.891906+00:00 app[web.1]:
2016-06-02T18:06:43.891934+00:00 app[web.1]: *-> Are "grunt" and related grunt task modules installed locally? Run `npm install` if you're not sure.
2016-06-02T18:06:43.891899+00:00 app[web.1]: Troubleshooting tips:
2016-06-02T18:06:43.891390+00:00 app[web.1]:
2016-06-02T18:06:43.891433+00:00 app[web.1]: Or if you're stuck, check out the troubleshooting tips below.
2016-06-02T18:06:43.891476+00:00 app[web.1]:
2016-06-02T18:06:43.891189+00:00 app[web.1]:
2016-06-02T18:06:43.892016+00:00 app[web.1]: *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
2016-06-02T18:06:43.891973+00:00 app[web.1]:
2016-06-02T18:06:43.892187+00:00 app[web.1]:
2016-06-02T18:06:43.892084+00:00 app[web.1]:
2016-06-02T18:06:43.892304+00:00 app[web.1]:
2016-06-02T18:06:43.892265+00:00 app[web.1]: sudo chown -R 59724 /app/.tmp
2016-06-02T18:06:43.892088+00:00 app[web.1]: *-> Or maybe you don't have permissions to access the `.tmp` directory?
2016-06-02T18:06:43.892144+00:00 app[web.1]: e.g., `/app/.tmp` ?
2016-06-02T18:06:43.892259+00:00 app[web.1]: If you think this might be the case, try running:
2016-06-02T18:06:59.974471+00:00 app[web.1]: at Timeout.tooLong [as _onTimeout] (/app/node_modules/sails/lib/app/private/loadHooks.js:85:21)
2016-06-02T18:06:59.974435+00:00 app[web.1]: Error: The hook `grunt` is taking too long to load.
2016-06-02T18:06:59.974469+00:00 app[web.1]: Make sure it is triggering its `initialize()` callback, or else set `sails.config.grunt._hookTimeout to a higher value (currently 20000)
2016-06-02T18:06:59.974474+00:00 app[web.1]: Make sure it is triggering its `initialize()` callback, or else set `sails.config.grunt._hookTimeout to a higher value (currently 20000)] code: 'E_HOOK_TIMEOUT' }
2016-06-02T18:06:59.974473+00:00 app[web.1]: at Timer.listOnTimeout (timers.js:198:5) { [Error: The hook `grunt` is taking too long to load.
2016-06-02T18:06:59.974472+00:00 app[web.1]: at tryOnTimeout (timers.js:224:11)
2016-06-02T18:07:00.662956+00:00 heroku[web.1]: Process exited with status 0
2016-06-02T18:07:00.697875+00:00 heroku[web.1]: State changed from starting to crashed
$ more bower.json
{
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"bootstrap": "~3.3.6",
"fontawesome": "~4.6.3"
},
"exportsOverride": {
"bootstrap": {
"js": "dist/js/*.min.*",
"less": "less/"
},
"fontawesome": {
"less": "less/",
"fonts": "fonts/"
},
"jquery": {
".": "dist/*.min.*"
}
},
"name": "sails-website",
"version": "0.1.0",
"author": "joel",
"private": true
}
$ heroku run node_modules/.bin/grunt build
Running node_modules/.bin/grunt build on ⬢myapp-webrtc... up, run.3290
Running "bower:install" (bower) task
>> Cleaned target dir /app/assets/vendor
Fatal error: Path must be a string. Received [ '/tmp/3fc3abe767162452221ee2ffa49efa28/bower/fontawesome-3-h46jhs',
[Function: _cleanupCallback] ]
答案 0 :(得分:0)
Getting the error "Arguments to path.join must be strings"? Clear cache and update to Bower 1.3.8.
不确定这是必须的,但是因为我有了
version: '2'
services:
db:
image: mysql:5.7
volumes:
- "./.data/db:/var/lib/mysql"
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
links:
- db
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_PASSWORD: wordpress
$ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-nodejs#v90
$ heroku run bower cache clean
然后{
"scripts": {
"postinstall": "bower install; grunt build", <==== ADDED THIS LINE
"debug": "node debug app.js",
"start": "node app.js"
},
"dependencies": {
"bower": "1.3.8", <==== ADDED THIS TO MAKE SURE TO USE VERSION 1.3.8
"connect-redis": "^3.0.2",
"ejs": "2.3.4",
"grunt": "0.4.5",
"grunt-bower": "^0.21.2",
"grunt-bower-task": "^0.3.4",
"grunt-contrib-clean": "0.6.0",
"grunt-contrib-coffee": "0.13.0",
"grunt-contrib-concat": "0.5.1",
"grunt-contrib-copy": "0.5.0",
"grunt-contrib-cssmin": "0.9.0",
"grunt-contrib-jst": "0.6.0",
"grunt-contrib-less": "1.1.0",
"grunt-contrib-uglify": "0.7.0",
"grunt-contrib-watch": "0.5.3",
"grunt-sails-linker": "~0.10.1",
"grunt-sync": "0.2.4",
"include-all": "~0.1.6",
"rc": "1.0.1",
"sails": "~0.12.3",
"sails-disk": "~0.10.9"
},
"name": "myapp-sails-website",
"private": true,
"version": "0.0.0",
"description": "a Sails application",
"keywords": [],
"main": "app.js",
"repository": {
"type": "git",
"url": "git://github.com/joel/myapp.git"
},
"author": "joel",
"license": ""
}
git push heroku master
解决了我的问题。